{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Preparing the Input for 12-lead"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.7/site-packages/dask/config.py:161: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.\n",
      "  data = yaml.load(f.read()) or {}\n",
      "/anaconda3/lib/python3.7/site-packages/dask/dataframe/utils.py:13: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.\n",
      "  import pandas.util.testing as tm\n",
      "/anaconda3/lib/python3.7/site-packages/distributed/config.py:20: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.\n",
      "  defaults = yaml.load(f)\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "#import wfdb as wf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from biosppy.signals import ecg\n",
    "import glob\n",
    "from scipy import signal\n",
    "import pandas as pd\n",
    "from tensorflow.python.keras.layers import Dense, Convolution1D, Convolution2D,MaxPool1D, Flatten, Dropout\n",
    "from tensorflow.python.keras.layers import Input\n",
    "from tensorflow.python.keras.models import Model\n",
    "from tensorflow.python.keras.layers.normalization import BatchNormalization\n",
    "import tensorflow.python.keras\n",
    "from tensorflow.python.keras.callbacks import EarlyStopping, ModelCheckpoint\n",
    "from tensorflow.python.keras.utils.np_utils import to_categorical\n",
    "import tensorflow as tf\n",
    "from sklearn.metrics import confusion_matrix\n",
    "from sklearn.model_selection import StratifiedShuffleSplit\n",
    "from collections import Counter\n",
    "from sklearn import preprocessing\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import os,glob\n",
    "import math\n",
    "import fnmatch\n",
    "import re\n",
    "import gc\n",
    "import shutil\n",
    "from joblib import Parallel, delayed\n",
    "#import matplotlib.pyplot as plt\n",
    "import scipy.signal as scipysi\n",
    "import xgboost as xgb\n",
    "from sklearn.model_selection import StratifiedShuffleSplit\n",
    "from sklearn import metrics\n",
    "from sklearn.preprocessing import PolynomialFeatures\n",
    "from sklearn.ensemble import BaggingClassifier\n",
    "from sklearn.multiclass import OneVsRestClassifier\n",
    "from sklearn.multiclass import OneVsOneClassifier\n",
    "from sklearn.multiclass import OutputCodeClassifier\n",
    "from sklearn.ensemble import ExtraTreesClassifier\n",
    "from sklearn.neighbors import NearestCentroid\n",
    "from sklearn.neighbors import RadiusNeighborsClassifier\n",
    "from sklearn.linear_model import SGDClassifier\n",
    "from sklearn.linear_model import RidgeClassifier\n",
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "from sklearn import linear_model\n",
    "from sklearn.preprocessing import MinMaxScaler, MaxAbsScaler\n",
    "from sklearn.feature_selection import SelectFromModel\n",
    "import tensorflow as tf\n",
    "from tensorflow import keras\n",
    "from tensorflow.keras.layers import Bidirectional, GRU\n",
    "import shutil\n",
    "#import matplotlib as plt\n",
    "from tensorflow.python.keras.models import Model\n",
    "from tensorflow.python.keras.layers import Input, Dense, LSTM, multiply, concatenate, Activation, Masking, Reshape,CuDNNLSTM,GlobalMaxPooling1D, MaxPool2D,Flatten\n",
    "from tensorflow.python.keras.layers import Conv1D, Conv2D, BatchNormalization, GlobalAveragePooling1D, Permute, Dropout, GlobalAveragePooling2D,Concatenate\n",
    "from tensorflow import keras\n",
    "from tensorflow.keras import layers\n",
    "import numpy as np\n",
    "from imblearn.over_sampling import SMOTE, ADASYN, SVMSMOTE\n",
    "from sklearn import preprocessing\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from tensorflow.keras import initializers\n",
    "from tensorflow.keras import regularizers, constraints\n",
    "import tensorflow.keras.backend as K\n",
    "\n",
    "\n",
    "from sklearn.decomposition import PCA\n",
    "from mpl_toolkits.mplot3d import Axes3D\n",
    "from matplotlib.colors import ListedColormap\n",
    "\n",
    "from scipy import signal\n",
    "from scipy.fft import fftshift"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Loading data and playing with it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#constants\n",
    "\n",
    "TARGET_SAMPLING_RATE=250\n",
    "DATA_SAMPLING_RATE=500\n",
    "INPUT_BEAT_SIZE=300\n",
    "\n",
    "#paths\n",
    "root_path='/Users/aring/Desktop/ECG-identification/Arnold-data'\n",
    "\n",
    "DataFilePath = root_path+'/NoiseReductionData/'\n",
    "LeadInfoFilePath = root_path+'/DiagnosisFiles/MissingLeadInfo/'\n",
    "RepDiagnosisFileName = root_path+'/DiagnosisFiles/RepatTranslationDiagAfterRemDupAndBDQ_CHS20200531_ToArinG.xlsx'\n",
    "FullDiagnosisFileName = root_path+'/DiagnosisFiles/TranslationDiagAfterRemDupAndBDQ_CHS20200531_ToArinG.xlsx'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FileName</th>\n",
       "      <th>PatientID</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "      <th>TimeAcquisition</th>\n",
       "      <th>Translation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MUSE_20180113_180130_23000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>85</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/12/2016 10:52:16</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MUSE_20180113_180131_30000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/05/2017 10:10:54</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUSE_20180113_180139_35000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>03/06/2017 07:34:27</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MUSE_20180113_180143_59000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>04/11/2017 11:46:50</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MUSE_20180113_131105_22000</td>\n",
       "      <td>542</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Female</td>\n",
       "      <td>26/01/2017 12:50:33</td>\n",
       "      <td>[ 'Ventricular_Escape_Beat']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     FileName  PatientID        DOB Age     Gen  \\\n",
       "0  MUSE_20180113_180130_23000        219  1011931.0  85    Male   \n",
       "1  MUSE_20180113_180131_30000        219  1011931.0  86    Male   \n",
       "2  MUSE_20180113_180139_35000        219  1011931.0  86    Male   \n",
       "3  MUSE_20180113_180143_59000        219  1011931.0  86    Male   \n",
       "4  MUSE_20180113_131105_22000        542  1011931.0  86  Female   \n",
       "\n",
       "       TimeAcquisition                   Translation  \n",
       "0  29/12/2016 10:52:16         ['Sinus_Tachycardia']  \n",
       "1  29/05/2017 10:10:54         ['Sinus_Tachycardia']  \n",
       "2  03/06/2017 07:34:27         ['Sinus_Tachycardia']  \n",
       "3  04/11/2017 11:46:50         ['Sinus_Tachycardia']  \n",
       "4  26/01/2017 12:50:33  [ 'Ventricular_Escape_Beat']  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "RepDiagnosisDF = pd.read_excel(RepDiagnosisFileName)\n",
    "RepDiagnosisDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "FullDiagnosisDF = pd.read_excel(FullDiagnosisFileName)\n",
    "FullDiagnosisDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(223, 2)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=RepDiagnosisDF.groupby(['PatientID']).size().reset_index(name='count')\n",
    "a=a.sort_values(by=['count'],ascending=False)\n",
    "a[a['count']>4].shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 304,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "NonRepDiagnosisDF = FullDiagnosisDF.loc[~FullDiagnosisDF['FileName'].isin(RepDiagnosisDF['FileName'])]\n",
    "NonRepDiagnosisDF = NonRepDiagnosisDF.reset_index(drop=True)\n",
    "NonRepDiagnosisDF['PatientID'] = NonRepDiagnosisDF['FileName']\n",
    "\n",
    "AllDiagnosisDF = pd.concat([RepDiagnosisDF, NonRepDiagnosisDF])\n",
    "AllDiagnosisDF = AllDiagnosisDF.reset_index(drop=True)\n",
    "le = preprocessing.LabelEncoder()\n",
    "AllDiagnosisDF['PatientID_new'] = AllDiagnosisDF['PatientID'].astype('str')\n",
    "AllDiagnosisDF['PatientID_new'] = le.fit_transform(AllDiagnosisDF['PatientID_new'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 305,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FileName</th>\n",
       "      <th>PatientID</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "      <th>TimeAcquisition</th>\n",
       "      <th>Translation</th>\n",
       "      <th>PatientID_new</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MUSE_20180113_180130_23000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>85</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/12/2016 10:52:16</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MUSE_20180113_180131_30000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/05/2017 10:10:54</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUSE_20180113_180139_35000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>03/06/2017 07:34:27</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MUSE_20180113_180143_59000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>04/11/2017 11:46:50</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MUSE_20180113_131105_22000</td>\n",
       "      <td>542</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Female</td>\n",
       "      <td>26/01/2017 12:50:33</td>\n",
       "      <td>[ 'Ventricular_Escape_Beat']</td>\n",
       "      <td>2269</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     FileName PatientID        DOB Age     Gen  \\\n",
       "0  MUSE_20180113_180130_23000       219  1011931.0  85    Male   \n",
       "1  MUSE_20180113_180131_30000       219  1011931.0  86    Male   \n",
       "2  MUSE_20180113_180139_35000       219  1011931.0  86    Male   \n",
       "3  MUSE_20180113_180143_59000       219  1011931.0  86    Male   \n",
       "4  MUSE_20180113_131105_22000       542  1011931.0  86  Female   \n",
       "\n",
       "       TimeAcquisition                   Translation  PatientID_new  \n",
       "0  29/12/2016 10:52:16         ['Sinus_Tachycardia']           1673  \n",
       "1  29/05/2017 10:10:54         ['Sinus_Tachycardia']           1673  \n",
       "2  03/06/2017 07:34:27         ['Sinus_Tachycardia']           1673  \n",
       "3  04/11/2017 11:46:50         ['Sinus_Tachycardia']           1673  \n",
       "4  26/01/2017 12:50:33  [ 'Ventricular_Escape_Beat']           2269  "
      ]
     },
     "execution_count": 305,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AllDiagnosisDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 308,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FileName</th>\n",
       "      <th>PatientID</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "      <th>TimeAcquisition</th>\n",
       "      <th>Translation</th>\n",
       "      <th>PatientID_new</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1917</th>\n",
       "      <td>MUSE_20180113_115320_38000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>16/11/2016 08:45:50</td>\n",
       "      <td>['Aberrant_Ventricular_Conduction', 'Atrial_Fi...</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1918</th>\n",
       "      <td>MUSE_20180113_115322_56000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>03/05/2017 10:40:54</td>\n",
       "      <td>['Atrial_Flutter', 'Intraventricular_Block']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1919</th>\n",
       "      <td>MUSE_20180113_115323_64000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>03/05/2017 09:20:45</td>\n",
       "      <td>['Atrial_Flutter', 'Intraventricular_Block']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1920</th>\n",
       "      <td>MUSE_20180113_115325_79000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>07/06/2017 10:03:37</td>\n",
       "      <td>['Atrial_Flutter', 'Intraventricular_Block']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1921</th>\n",
       "      <td>MUSE_20180113_115326_85000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>17/05/2017 09:49:30</td>\n",
       "      <td>['Atrial_Flutter', 'Intraventricular_Block']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1922</th>\n",
       "      <td>MUSE_20180113_115319_29000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>16/11/2016 10:27:16</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1923</th>\n",
       "      <td>MUSE_20180113_115321_49000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>19/04/2017 09:29:51</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1924</th>\n",
       "      <td>MUSE_20180113_115324_71000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>28/06/2017 10:58:31</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1925</th>\n",
       "      <td>MUSE_20180113_115329_14000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>21/09/2016 08:56:45</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1926</th>\n",
       "      <td>MUSE_20180113_115330_21000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>28/09/2016 09:40:30</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1927</th>\n",
       "      <td>MUSE_20180113_115332_39000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>15/06/2016 08:12:11</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1928</th>\n",
       "      <td>MUSE_20180113_115341_58000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>22/06/2016 08:14:41</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1929</th>\n",
       "      <td>MUSE_20180113_115343_73000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>06/12/2017 10:27:40</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1930</th>\n",
       "      <td>MUSE_20180113_115346_96000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>25/10/2017 10:26:01</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1931</th>\n",
       "      <td>MUSE_20180113_115348_04000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>11/10/2017 09:28:48</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1932</th>\n",
       "      <td>MUSE_20180113_115350_17000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>19/07/2017 10:19:06</td>\n",
       "      <td>['Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1933</th>\n",
       "      <td>MUSE_20180113_115342_65000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/06/2016 09:02:52</td>\n",
       "      <td>['Atrial_Premature_Beat', 'Atrial_Tachycardia'...</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1934</th>\n",
       "      <td>MUSE_20180120_122946_28000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>70</td>\n",
       "      <td>Male</td>\n",
       "      <td>17/01/2018 10:42:33</td>\n",
       "      <td>['Atrial_Premature_Beat', 'Sinus_Bradycardia']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1935</th>\n",
       "      <td>MUSE_20180113_115318_19000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>01/03/2017 08:57:09</td>\n",
       "      <td>['AVBlock', 'Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1936</th>\n",
       "      <td>MUSE_20180113_115345_90000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>13/09/2017 10:18:44</td>\n",
       "      <td>['AVBlock', 'Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1937</th>\n",
       "      <td>MUSE_20180113_115349_11000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>09/08/2017 09:28:24</td>\n",
       "      <td>['AVBlock', 'Atrial_Flutter']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1938</th>\n",
       "      <td>MUSE_20180113_115331_30000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>24/08/2016 08:52:03</td>\n",
       "      <td>['Sinus_Bradycardia']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1939</th>\n",
       "      <td>MUSE_20180113_115340_49000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>01/06/2016 11:10:49</td>\n",
       "      <td>['Sinus_Bradycardia']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1940</th>\n",
       "      <td>MUSE_20180113_115344_82000</td>\n",
       "      <td>4181664</td>\n",
       "      <td>1011948.0</td>\n",
       "      <td>69</td>\n",
       "      <td>Male</td>\n",
       "      <td>08/11/2017 09:37:11</td>\n",
       "      <td>['Sinus_Bradycardia']</td>\n",
       "      <td>2145</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        FileName PatientID        DOB Age   Gen  \\\n",
       "1917  MUSE_20180113_115320_38000   4181664  1011948.0  68  Male   \n",
       "1918  MUSE_20180113_115322_56000   4181664  1011948.0  69  Male   \n",
       "1919  MUSE_20180113_115323_64000   4181664  1011948.0  69  Male   \n",
       "1920  MUSE_20180113_115325_79000   4181664  1011948.0  69  Male   \n",
       "1921  MUSE_20180113_115326_85000   4181664  1011948.0  69  Male   \n",
       "1922  MUSE_20180113_115319_29000   4181664  1011948.0  68  Male   \n",
       "1923  MUSE_20180113_115321_49000   4181664  1011948.0  69  Male   \n",
       "1924  MUSE_20180113_115324_71000   4181664  1011948.0  69  Male   \n",
       "1925  MUSE_20180113_115329_14000   4181664  1011948.0  68  Male   \n",
       "1926  MUSE_20180113_115330_21000   4181664  1011948.0  68  Male   \n",
       "1927  MUSE_20180113_115332_39000   4181664  1011948.0  68  Male   \n",
       "1928  MUSE_20180113_115341_58000   4181664  1011948.0  68  Male   \n",
       "1929  MUSE_20180113_115343_73000   4181664  1011948.0  69  Male   \n",
       "1930  MUSE_20180113_115346_96000   4181664  1011948.0  69  Male   \n",
       "1931  MUSE_20180113_115348_04000   4181664  1011948.0  69  Male   \n",
       "1932  MUSE_20180113_115350_17000   4181664  1011948.0  69  Male   \n",
       "1933  MUSE_20180113_115342_65000   4181664  1011948.0  68  Male   \n",
       "1934  MUSE_20180120_122946_28000   4181664  1011948.0  70  Male   \n",
       "1935  MUSE_20180113_115318_19000   4181664  1011948.0  69  Male   \n",
       "1936  MUSE_20180113_115345_90000   4181664  1011948.0  69  Male   \n",
       "1937  MUSE_20180113_115349_11000   4181664  1011948.0  69  Male   \n",
       "1938  MUSE_20180113_115331_30000   4181664  1011948.0  68  Male   \n",
       "1939  MUSE_20180113_115340_49000   4181664  1011948.0  68  Male   \n",
       "1940  MUSE_20180113_115344_82000   4181664  1011948.0  69  Male   \n",
       "\n",
       "          TimeAcquisition                                        Translation  \\\n",
       "1917  16/11/2016 08:45:50  ['Aberrant_Ventricular_Conduction', 'Atrial_Fi...   \n",
       "1918  03/05/2017 10:40:54       ['Atrial_Flutter', 'Intraventricular_Block']   \n",
       "1919  03/05/2017 09:20:45       ['Atrial_Flutter', 'Intraventricular_Block']   \n",
       "1920  07/06/2017 10:03:37       ['Atrial_Flutter', 'Intraventricular_Block']   \n",
       "1921  17/05/2017 09:49:30       ['Atrial_Flutter', 'Intraventricular_Block']   \n",
       "1922  16/11/2016 10:27:16                                 ['Atrial_Flutter']   \n",
       "1923  19/04/2017 09:29:51                                 ['Atrial_Flutter']   \n",
       "1924  28/06/2017 10:58:31                                 ['Atrial_Flutter']   \n",
       "1925  21/09/2016 08:56:45                                 ['Atrial_Flutter']   \n",
       "1926  28/09/2016 09:40:30                                 ['Atrial_Flutter']   \n",
       "1927  15/06/2016 08:12:11                                 ['Atrial_Flutter']   \n",
       "1928  22/06/2016 08:14:41                                 ['Atrial_Flutter']   \n",
       "1929  06/12/2017 10:27:40                                 ['Atrial_Flutter']   \n",
       "1930  25/10/2017 10:26:01                                 ['Atrial_Flutter']   \n",
       "1931  11/10/2017 09:28:48                                 ['Atrial_Flutter']   \n",
       "1932  19/07/2017 10:19:06                                 ['Atrial_Flutter']   \n",
       "1933  29/06/2016 09:02:52  ['Atrial_Premature_Beat', 'Atrial_Tachycardia'...   \n",
       "1934  17/01/2018 10:42:33     ['Atrial_Premature_Beat', 'Sinus_Bradycardia']   \n",
       "1935  01/03/2017 08:57:09                      ['AVBlock', 'Atrial_Flutter']   \n",
       "1936  13/09/2017 10:18:44                      ['AVBlock', 'Atrial_Flutter']   \n",
       "1937  09/08/2017 09:28:24                      ['AVBlock', 'Atrial_Flutter']   \n",
       "1938  24/08/2016 08:52:03                              ['Sinus_Bradycardia']   \n",
       "1939  01/06/2016 11:10:49                              ['Sinus_Bradycardia']   \n",
       "1940  08/11/2017 09:37:11                              ['Sinus_Bradycardia']   \n",
       "\n",
       "      PatientID_new  \n",
       "1917           2145  \n",
       "1918           2145  \n",
       "1919           2145  \n",
       "1920           2145  \n",
       "1921           2145  \n",
       "1922           2145  \n",
       "1923           2145  \n",
       "1924           2145  \n",
       "1925           2145  \n",
       "1926           2145  \n",
       "1927           2145  \n",
       "1928           2145  \n",
       "1929           2145  \n",
       "1930           2145  \n",
       "1931           2145  \n",
       "1932           2145  \n",
       "1933           2145  \n",
       "1934           2145  \n",
       "1935           2145  \n",
       "1936           2145  \n",
       "1937           2145  \n",
       "1938           2145  \n",
       "1939           2145  \n",
       "1940           2145  "
      ]
     },
     "execution_count": 308,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AllDiagnosisDF[AllDiagnosisDF['PatientID']==4181664]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FileName</th>\n",
       "      <th>PatientID</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "      <th>TimeAcquisition</th>\n",
       "      <th>Translation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MUSE_20180115_124154_98000</td>\n",
       "      <td>880947374</td>\n",
       "      <td>1012016.0</td>\n",
       "      <td>20</td>\n",
       "      <td>Female</td>\n",
       "      <td>25/09/2017 15:32:26</td>\n",
       "      <td>[  'Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MUSE_20180112_071158_01000</td>\n",
       "      <td>880957431</td>\n",
       "      <td>1012016.0</td>\n",
       "      <td>22</td>\n",
       "      <td>Female</td>\n",
       "      <td>16/11/2017 15:55:09</td>\n",
       "      <td>[  'Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUSE_20180114_123835_64000</td>\n",
       "      <td>880878772</td>\n",
       "      <td>1011949.0</td>\n",
       "      <td>67</td>\n",
       "      <td>Female</td>\n",
       "      <td>26/10/2016 10:55:48</td>\n",
       "      <td>[ 'Clockwise_Rotation', 'Complete_LBBB', 'Sinu...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MUSE_20180210_124733_04000</td>\n",
       "      <td>2968425</td>\n",
       "      <td>1011949.0</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "      <td>04/11/2017 19:30:02</td>\n",
       "      <td>[ 'Clockwise_Rotation', 'Myocardial_Infarction...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MUSE_20180118_173322_76000</td>\n",
       "      <td>10956457</td>\n",
       "      <td>1011952.0</td>\n",
       "      <td>65</td>\n",
       "      <td>Female</td>\n",
       "      <td>10/05/2017 10:35:22</td>\n",
       "      <td>[ 'Clockwise_Rotation', 'Sinus_Tachycardia']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45303</th>\n",
       "      <td>MUSE_20180116_121305_58000</td>\n",
       "      <td>880938543</td>\n",
       "      <td>1011981.0</td>\n",
       "      <td>36</td>\n",
       "      <td>Male</td>\n",
       "      <td>15/08/2017 16:32:00</td>\n",
       "      <td>['VT']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45304</th>\n",
       "      <td>MUSE_20180120_123539_01000</td>\n",
       "      <td>880968276</td>\n",
       "      <td>1011988.0</td>\n",
       "      <td>30</td>\n",
       "      <td>Female</td>\n",
       "      <td>16/01/2018 18:06:02</td>\n",
       "      <td>['VT']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45305</th>\n",
       "      <td>MUSE_20180120_122254_36000</td>\n",
       "      <td>10183314</td>\n",
       "      <td>1012010.0</td>\n",
       "      <td>6</td>\n",
       "      <td>Female</td>\n",
       "      <td>23/11/2016 20:19:05</td>\n",
       "      <td>['Wandering_Pacemakerwithin_Sinoatrial_Node']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45306</th>\n",
       "      <td>MUSE_20180116_124311_28000</td>\n",
       "      <td>11106793</td>\n",
       "      <td>1011938.0</td>\n",
       "      <td>78</td>\n",
       "      <td>Female</td>\n",
       "      <td>16/01/2016 11:41:35</td>\n",
       "      <td>['Wandering_Pacemakerwithin_Sinoatrial_Node']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45307</th>\n",
       "      <td>MUSE_20180119_180042_46000</td>\n",
       "      <td>880832808</td>\n",
       "      <td>1011967.0</td>\n",
       "      <td>49</td>\n",
       "      <td>Male</td>\n",
       "      <td>09/03/2016 08:53:37</td>\n",
       "      <td>['Wandering_Pacemakerwithin_Sinoatrial_Node']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>45308 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                         FileName  PatientID        DOB Age     Gen  \\\n",
       "0      MUSE_20180115_124154_98000  880947374  1012016.0  20  Female   \n",
       "1      MUSE_20180112_071158_01000  880957431  1012016.0  22  Female   \n",
       "2      MUSE_20180114_123835_64000  880878772  1011949.0  67  Female   \n",
       "3      MUSE_20180210_124733_04000    2968425  1011949.0  68    Male   \n",
       "4      MUSE_20180118_173322_76000   10956457  1011952.0  65  Female   \n",
       "...                           ...        ...        ...  ..     ...   \n",
       "45303  MUSE_20180116_121305_58000  880938543  1011981.0  36    Male   \n",
       "45304  MUSE_20180120_123539_01000  880968276  1011988.0  30  Female   \n",
       "45305  MUSE_20180120_122254_36000   10183314  1012010.0   6  Female   \n",
       "45306  MUSE_20180116_124311_28000   11106793  1011938.0  78  Female   \n",
       "45307  MUSE_20180119_180042_46000  880832808  1011967.0  49    Male   \n",
       "\n",
       "           TimeAcquisition                                        Translation  \n",
       "0      25/09/2017 15:32:26                            [  'Sinus_Tachycardia']  \n",
       "1      16/11/2017 15:55:09                            [  'Sinus_Tachycardia']  \n",
       "2      26/10/2016 10:55:48  [ 'Clockwise_Rotation', 'Complete_LBBB', 'Sinu...  \n",
       "3      04/11/2017 19:30:02  [ 'Clockwise_Rotation', 'Myocardial_Infarction...  \n",
       "4      10/05/2017 10:35:22       [ 'Clockwise_Rotation', 'Sinus_Tachycardia']  \n",
       "...                    ...                                                ...  \n",
       "45303  15/08/2017 16:32:00                                             ['VT']  \n",
       "45304  16/01/2018 18:06:02                                             ['VT']  \n",
       "45305  23/11/2016 20:19:05      ['Wandering_Pacemakerwithin_Sinoatrial_Node']  \n",
       "45306  16/01/2016 11:41:35      ['Wandering_Pacemakerwithin_Sinoatrial_Node']  \n",
       "45307  09/03/2016 08:53:37      ['Wandering_Pacemakerwithin_Sinoatrial_Node']  \n",
       "\n",
       "[45308 rows x 7 columns]"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "FullDiagnosisDF = pd.read_excel(FullDiagnosisFileName)\n",
    "FullDiagnosisDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(45308, 7)"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "FullDiagnosisDF.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PatientID</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>880947374</td>\n",
       "      <td>20</td>\n",
       "      <td>Female</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>880957431</td>\n",
       "      <td>22</td>\n",
       "      <td>Female</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>880878772</td>\n",
       "      <td>67</td>\n",
       "      <td>Female</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2968425</td>\n",
       "      <td>68</td>\n",
       "      <td>Male</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10956457</td>\n",
       "      <td>65</td>\n",
       "      <td>Female</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PatientID Age     Gen\n",
       "0  880947374  20  Female\n",
       "1  880957431  22  Female\n",
       "2  880878772  67  Female\n",
       "3    2968425  68    Male\n",
       "4   10956457  65  Female"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_gender_df=FullDiagnosisDF[['PatientID','Age','Gen']]\n",
    "age_gender_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [],
   "source": [
    "age_gender_df.to_csv('/Users/aring/Desktop/ECG-identification/age_gender.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Var1</th>\n",
       "      <th>Var2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Var1   Var2\n",
       "0  True  False\n",
       "1  True  False\n",
       "2  True  False\n",
       "3  True  False\n",
       "4  True  False"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "leadinfoDF = pd.read_excel(LeadInfoFilePath + 'MUSE_20180111_170356_27000' + '.xlsx')\n",
    "leadinfoDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(12, 2)"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "leadinfoDF.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-44.944</td>\n",
       "      <td>-16.279</td>\n",
       "      <td>8.5933</td>\n",
       "      <td>25.355</td>\n",
       "      <td>-26.101</td>\n",
       "      <td>-6.0976</td>\n",
       "      <td>-51.235</td>\n",
       "      <td>-57.090</td>\n",
       "      <td>-45.905</td>\n",
       "      <td>-54.620</td>\n",
       "      <td>-21.231</td>\n",
       "      <td>14.0490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-50.910</td>\n",
       "      <td>-22.374</td>\n",
       "      <td>8.6467</td>\n",
       "      <td>31.734</td>\n",
       "      <td>-28.214</td>\n",
       "      <td>-8.6359</td>\n",
       "      <td>-51.259</td>\n",
       "      <td>-60.730</td>\n",
       "      <td>-49.903</td>\n",
       "      <td>-57.047</td>\n",
       "      <td>-24.873</td>\n",
       "      <td>7.9470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-57.153</td>\n",
       "      <td>-29.420</td>\n",
       "      <td>8.0254</td>\n",
       "      <td>38.785</td>\n",
       "      <td>-30.269</td>\n",
       "      <td>-12.1520</td>\n",
       "      <td>-51.659</td>\n",
       "      <td>-64.809</td>\n",
       "      <td>-53.887</td>\n",
       "      <td>-59.625</td>\n",
       "      <td>-29.008</td>\n",
       "      <td>1.6642</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-63.350</td>\n",
       "      <td>-37.508</td>\n",
       "      <td>6.3144</td>\n",
       "      <td>46.402</td>\n",
       "      <td>-31.999</td>\n",
       "      <td>-16.9680</td>\n",
       "      <td>-52.452</td>\n",
       "      <td>-69.387</td>\n",
       "      <td>-57.537</td>\n",
       "      <td>-62.235</td>\n",
       "      <td>-33.709</td>\n",
       "      <td>-4.5832</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-68.634</td>\n",
       "      <td>-45.746</td>\n",
       "      <td>3.5399</td>\n",
       "      <td>53.644</td>\n",
       "      <td>-33.037</td>\n",
       "      <td>-22.5800</td>\n",
       "      <td>-53.271</td>\n",
       "      <td>-74.064</td>\n",
       "      <td>-60.240</td>\n",
       "      <td>-64.508</td>\n",
       "      <td>-38.522</td>\n",
       "      <td>-10.1500</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0       1       2       3       4        5       6       7       8   \\\n",
       "0 -44.944 -16.279  8.5933  25.355 -26.101  -6.0976 -51.235 -57.090 -45.905   \n",
       "1 -50.910 -22.374  8.6467  31.734 -28.214  -8.6359 -51.259 -60.730 -49.903   \n",
       "2 -57.153 -29.420  8.0254  38.785 -30.269 -12.1520 -51.659 -64.809 -53.887   \n",
       "3 -63.350 -37.508  6.3144  46.402 -31.999 -16.9680 -52.452 -69.387 -57.537   \n",
       "4 -68.634 -45.746  3.5399  53.644 -33.037 -22.5800 -53.271 -74.064 -60.240   \n",
       "\n",
       "       9       10       11  \n",
       "0 -54.620 -21.231  14.0490  \n",
       "1 -57.047 -24.873   7.9470  \n",
       "2 -59.625 -29.008   1.6642  \n",
       "3 -62.235 -33.709  -4.5832  \n",
       "4 -64.508 -38.522 -10.1500  "
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample_record = pd.read_csv(DataFilePath + 'noise-reduc-all/NoiseReductionData/'+'MUSE_20180112_070939_20000' + '.csv', header=None)\n",
    "sample_record.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5000, 12)"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample_record.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n",
      "300\n"
     ]
    }
   ],
   "source": [
    "channel = sample_record[0].values\n",
    "ecg_info_extracted = ecg.ecg(signal=channel, sampling_rate=DATA_SAMPLING_RATE, show=False)\n",
    "num_of_beats=ecg_info_extracted['templates'].shape[0]\n",
    "beat_size=ecg_info_extracted['templates'].shape[1]\n",
    "print(num_of_beats)\n",
    "print(beat_size)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19, 300)"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "heart_beats_12lead = np.array(ecg_info_extracted['templates'], dtype=np.float)\n",
    "heart_beats_12lead.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19, 600)"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "channel = sample_record[1].values\n",
    "ecg_info_extracted = ecg.ecg(signal=channel, sampling_rate=DATA_SAMPLING_RATE, show=False)\n",
    "heart_beats_12lead=np.append(heart_beats_12lead,ecg_info_extracted['templates'],1)\n",
    "heart_beats_12lead.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "has all leads!\n"
     ]
    }
   ],
   "source": [
    "if any(~leadinfoDF.iloc[:, 0]):\n",
    "    print('missing some leaseds!')\n",
    "else:\n",
    "     print('has all leads!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19, 3600)"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#this creates a matrix where  each row is a beat, 12 leads stored one after another in that row (each lead is 300 smaples)\n",
    "for i in [1,0,2,3,4,5,6,7,8,9,10,11]:\n",
    "    channel = sample_record[i].values\n",
    "    try:\n",
    "        ecg_info_extracted = ecg.ecg(signal=channel, sampling_rate=DATA_SAMPLING_RATE, show=False)\n",
    "        if i==1:\n",
    "            heart_beats_12lead = np.array(ecg_info_extracted['templates'], dtype=np.float)\n",
    "            lead1_beats=ecg_info_extracted['templates']\n",
    "        else:\n",
    "            heart_beats_12lead = np.append(heart_beats_12lead,ecg_info_extracted['templates'],1)\n",
    "    except Exception as e:\n",
    "        if i==1:\n",
    "            break\n",
    "        print('error in processing the leads:'+ str(i))\n",
    "        heart_beats_12lead = np.append(heart_beats_12lead,np.zeros_like(lead1_beats),1)\n",
    "        continue\n",
    "\n",
    "\n",
    "heart_beats_12lead.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(19, 300)"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ecg_info_extracted['templates'].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-18.13456949, -17.62687377, -17.08459724, ..., -20.57877766,\n",
       "        -23.10124215, -25.19957523],\n",
       "       [-17.13388225, -16.28698359, -15.31613171, ..., -21.90872581,\n",
       "        -23.85870663, -24.6684356 ],\n",
       "       [-13.35416922, -13.0744338 , -12.77143781, ..., -17.46681087,\n",
       "        -19.04744205, -21.00455269],\n",
       "       ...,\n",
       "       [-14.77531711, -14.28855901, -13.87134876, ..., -18.76016624,\n",
       "        -18.4452355 , -19.0769272 ],\n",
       "       [-13.35531235, -12.73198025, -12.17661534, ...,  -7.53141091,\n",
       "         -8.95909886, -10.90518262],\n",
       "       [-14.32165088, -13.3106402 , -12.43055031, ..., -11.62177154,\n",
       "        -12.16643547, -13.23792191]])"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "heart_beats_12lead[:,2*300:3*300]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(12, 300)"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "beat1_12lead = np.reshape(heart_beats_12lead[0], (12, 300))\n",
    "beat1_12lead.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD8CAYAAACCRVh7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3XeYXNVh///3uWV62Zlt2r7qXQgkhBBFohgM7sbdwRjsYBznFyexU5zmJHZiJ9/EcUlsQtzAIbEBmxhTDDKmCiGxoqh3rba32d3pc+v5/TGLAIPAYNAIc17Ps8/u3Dn3zpmdO/OZU+69QkqJoiiKorwQrdYVUBRFUU5eKiQURVGU41IhoSiKohyXCglFURTluFRIKIqiKMelQkJRFEU5LhUSiqIoynGpkFAURVGOS4WEoiiKclxGrSvwm2poaJDd3d21roaiKMrryrZt2yaklI0vVe51HxLd3d309PTUuhqKoiivK0KIo79OOdXdpCiKohyXCglFURTluFRIKIqiKMelQkJRFEU5LhUSiqIoynGpkFAURVGOS4WEoiiKclwqJJSTyi0jkwxU7FpXQ1GUGa/7g+mU3x4TlsPv7+kDYM/Zy0iZavdUlFpTLQnlpLE/23/s7/8eytSwJoqiPE2FhHLSOJAdOPZ3f8WqYU0URXmaCgnlpHG4MAlAkxxhsKhaEopyMlCdvspJo7dskWKaJkYYrkRrXR1FUVAtCeUkMmDrtBoV0qLAhKu+vy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TgolIRkQaZp4DNxDtNX4fUYp1qL9U69Xqfh/wgfhOmmuB8Zmhj9XqtHH5dxJdG6iePn9ViMet/wbYb4z5+pxDdXdtqrWlHq+NiOREpDl+ngLeRDTHUm1rhbnX6xbgVyaexT5nKz17vxIPojszniUa2/vsStdnkXXfTHQnxh5g70z9icYdfwkcjP9tXem6Vqn/D4i6+hWiTz0frlZ3oq7zN+Lr9BTQs9L1X0Bb7orr+mT8C9s55/zPxm05ANy40vU/rS2vIRqWeBLYHT9uqsdrc4a21N21AbYDT8R1fhr4XFy+mSiQ9QJ/D3hxeTL+ujc+vnmpddAV10oppaq6EIeblFJKLZAGCaWUUlVpkFBKKVWVBgmllFJVaZBQSilVlQYJpZRSVWmQUEopVZUGCaWUUlX9f09HgnQTk+okAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#draw all 12 leads for the first beat\n",
    "for i in range(0,11):\n",
    "    plt.plot( beat1_12lead[i,:]) \n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(12, 301)\n"
     ]
    }
   ],
   "source": [
    "#add the lalber to each row for each beat\n",
    "beat1_12lead\n",
    "num_patientID=123\n",
    "label_column = np.repeat(num_patientID, beat1_12lead.shape[0])\n",
    "label_column=np.reshape(label_column, (label_column.shape[0], 1))\n",
    "beat1_12lead_with_label=np.append(beat1_12lead,label_column,1)\n",
    "print(beat1_12lead_with_label.shape)\n",
    "# print(beat1_12lead_with_label[0,])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Preprocssing 12-lead data and Storing the input to NN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "def generate_12lead_input_for_NN(num_patientID, diagnosis, signalFile):\n",
    "    NoiseReductionData_dirs=['NoiseReductionData1','NoiseReductionData2','NoiseReductionData3','NoiseReductionData4','NoiseReductionData5','NoiseReductionData6']\n",
    "    path_does_not_Exist=True\n",
    "    for dir_name in NoiseReductionData_dirs:\n",
    "        path = DataFilePath + dir_name+'/'+ signalFile + '.csv'\n",
    "        if os.path.exists(path):\n",
    "            path_does_not_Exist=False\n",
    "            break;\n",
    "    if path_does_not_Exist:\n",
    "        print('File does not exist:', signalFile)\n",
    "        return np.repeat(None, 1)\n",
    "    \n",
    "    all_beats_12lead_with_label_diagnosis = np.empty((0,12,INPUT_BEAT_SIZE+2), dtype=np.float)\n",
    "    record = pd.read_csv(path, header=None)\n",
    "    leadinfoDF = pd.read_excel(LeadInfoFilePath + signalFile + '.xlsx')\n",
    "    \n",
    "    for i in [1,0,2,3,4,5,6,7,8,9,10,11]:\n",
    "        channel = record[i].values\n",
    "        try:\n",
    "            ecg_info_extracted = ecg.ecg(signal=channel, sampling_rate=DATA_SAMPLING_RATE, show=False)\n",
    "            if i==1:\n",
    "                heart_beats_12lead = np.array(ecg_info_extracted['templates'], dtype=np.float)\n",
    "                lead1_beats=ecg_info_extracted['templates']\n",
    "                num_of_beats=lead1_beats.shape[0]\n",
    "            else:\n",
    "                heart_beats_12lead = np.append(heart_beats_12lead,ecg_info_extracted['templates'],1)\n",
    "        except Exception as e:\n",
    "            if i==1:\n",
    "                return np.repeat(None, 1)\n",
    "            else:\n",
    "                heart_beats_12lead = np.append(heart_beats_12lead,np.zeros_like(lead1_beats),1)\n",
    "                \n",
    "    for i in range(0,num_of_beats):\n",
    "        one_beat_12lead = np.reshape(heart_beats_12lead[i], (12, 300))\n",
    "        label_column = np.repeat(num_patientID, one_beat_12lead.shape[0])\n",
    "        label_column=np.reshape(label_column, (label_column.shape[0], 1))\n",
    "        diagnosis_column=np.repeat(diagnosis, one_beat_12lead.shape[0])\n",
    "        diagnosis_column=np.reshape(diagnosis_column, (diagnosis_column.shape[0], 1))\n",
    "        one_beat_12lead_with_label = np.append(one_beat_12lead,label_column,1)\n",
    "        one_beat_12lead_with_label_diagnosis = np.append(one_beat_12lead_with_label,diagnosis_column,1)\n",
    "        one_beat_12lead_with_label_diagnosis = np.reshape(one_beat_12lead_with_label_diagnosis,(1,12,302))\n",
    "        all_beats_12lead_with_label_diagnosis=np.vstack((all_beats_12lead_with_label_diagnosis,one_beat_12lead_with_label_diagnosis))\n",
    "    \n",
    "\n",
    "    return all_beats_12lead_with_label_diagnosis\n",
    "\n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "x=generate_12lead_input_for_NN(123,['Sinus_Tachycardia'],'MUSE_20180111_170356_27000')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['-40.719956926829624', '-40.844754001609466',\n",
       "        '-40.63335164906105', ..., '54.31228077099648', '123.0',\n",
       "        'Sinus_Tachycardia'],\n",
       "       ['-14.299994121880898', '-12.951280481990485',\n",
       "        '-11.416985294399705', ..., '14.764532947005735', '123.0',\n",
       "        'Sinus_Tachycardia'],\n",
       "       ['0.0', '0.0', '0.0', ..., '0.0', '123.0', 'Sinus_Tachycardia'],\n",
       "       ...,\n",
       "       ['-15.00218762655504', '-13.176144880710474',\n",
       "        '-11.256069088311921', ..., '34.55045611154739', '123.0',\n",
       "        'Sinus_Tachycardia'],\n",
       "       ['-3.9269471638104085', '-4.477020922562214',\n",
       "        '-4.846829608520115', ..., '22.714660699953154', '123.0',\n",
       "        'Sinus_Tachycardia'],\n",
       "       ['-16.29128183523312', '-14.2946982583345', '-12.115651880793529',\n",
       "        ..., '29.797783843492336', '123.0', 'Sinus_Tachycardia']],\n",
       "      dtype='<U32')"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "NonRepDiagnosisDF = FullDiagnosisDF.loc[~FullDiagnosisDF['FileName'].isin(RepDiagnosisDF['FileName'])]\n",
    "NonRepDiagnosisDF = NonRepDiagnosisDF.reset_index(drop=True)\n",
    "NonRepDiagnosisDF['PatientID'] = NonRepDiagnosisDF['FileName']\n",
    "\n",
    "AllDiagnosisDF = pd.concat([RepDiagnosisDF, NonRepDiagnosisDF])\n",
    "AllDiagnosisDF = AllDiagnosisDF.reset_index(drop=True)\n",
    "le = preprocessing.LabelEncoder()\n",
    "AllDiagnosisDF['PatientID'] = AllDiagnosisDF['PatientID'].astype('str')\n",
    "AllDiagnosisDF['PatientID'] = le.fit_transform(AllDiagnosisDF['PatientID'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.7/site-packages/joblib/externals/loky/process_executor.py:691: UserWarning: A worker stopped while some jobs were given to the executor. This can be caused by a too short worker timeout or by a memory leak.\n",
      "  \"timeout or by a memory leak.\", UserWarning\n"
     ]
    }
   ],
   "source": [
    "\n",
    "num_cores =6\n",
    "   \n",
    "\n",
    "results = Parallel(n_jobs=num_cores)(delayed(generate_12lead_input_for_NN)\n",
    "            (AllDiagnosisDF['PatientID'][indexFile],AllDiagnosisDF['Translation'][indexFile],signalFile) for indexFile, signalFile in enumerate(AllDiagnosisDF['FileName']))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/FeatureArray_stacked_pcs.csv'\n",
    "print('Generating ', outfn)\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, FeatureArray3, delimiter=\",\", fmt='%f')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "len(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def split_train_test(patient_rows):\n",
    "    random_rows=np.random.choice(patient_rows.shape[0], size=2, replace=False)\n",
    "    test=patient_rows[random_rows,:,:]\n",
    "    train=np.delete(patient_rows,random_rows,0)\n",
    "    return train,test\n",
    "\n",
    "train,test = map(list,zip(*[split_train_test(i) for i in results if  i.any()]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "print(len(train))\n",
    "print(len(test))\n",
    "num_of_people_in_data=len(train)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_stacked = np.row_stack(train)\n",
    "test_stacked = np.row_stack(test)\n",
    "\n",
    "print('train beats: '+str(train_stacked.shape))\n",
    "print('test beats: '+str(test_stacked.shape))\n",
    "print('total number of beats: '+str(train_stacked.shape[0]+test_stacked.shape[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_X=train_stacked[:,:,:-2]\n",
    "train_y=train_stacked[:,:,-2]\n",
    "train_diagnosis=train_stacked[:,:,-1]\n",
    "\n",
    "test_X=test_stacked[:,:,:-2]\n",
    "test_y=test_stacked[:,:,-2]\n",
    "test_diagnosis=train_stacked[:,:,-1]\n",
    "2\n",
    "\n",
    "print('train_X: '+str(train_X.shape))\n",
    "print('train_y: '+str(train_y.shape))\n",
    "print('train_diagnosis: '+str(train_diagnosis.shape))\n",
    "\n",
    "\n",
    "print('test_X: '+str(test_X.shape))\n",
    "print('test_X: '+str(test_y.shape))\n",
    "print('test_diagnosis: '+str(test_diagnosis.shape))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "# reshaping to 2D array so that npsavetxt can save it\n",
    "outfn = root_path+'/nn-input/train_X.csv'\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, train_X.reshape((train_X.shape[0],12*300)), delimiter=\",\", fmt='%f')\n",
    "\n",
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/nn-input/train_y.csv'\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, train_y, delimiter=\",\", fmt='%f')\n",
    "\n",
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/nn-input/test_X.csv'\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, test_X.reshape((test_X.shape[0],12*300)), delimiter=\",\", fmt='%f')\n",
    "\n",
    "    \n",
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/nn-input/test_y.csv'\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, test_y, delimiter=\",\", fmt='%f')\n",
    "    \n",
    "\n",
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/nn-input/test_diagnosis.csv'\n",
    "with open(outfn, \"wb\") as fin\n",
    "    np.savetxt(fin, test_diagnosis, delimiter=\",\", fmt='%f')\n",
    "    \n",
    "    \n",
    "\n",
    "\n",
    "# Save to CSV file.\n",
    "outfn = root_path+'/nn-input/train_diagnosis.csv'\n",
    "with open(outfn, \"wb\") as fin:\n",
    "    np.savetxt(fin, train_diagnosis, delimiter=\",\", fmt='%f')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### PCA\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "res_no_nulls = [i[:,:,:-2] for i in results if  i.any()] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "len(res_no_nulls)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "res_no_nulls[1].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "FeatureArray = np.row_stack(res_no_nulls)\n",
    "FeatureArray.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "FeatureArray2 = np.column_stack(FeatureArray)\n",
    "FeatureArray2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "FeatureArray3=FeatureArray2.transpose()\n",
    "FeatureArray3.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#draw all 12 leads for the first beat\n",
    "for i in range(0,11):\n",
    "    plt.plot( FeatureArray3[:300,i]) \n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "# a flexible function that plots 3d maps\n",
    "def plot3D(ds=None, labels=None, comp=None, fig=None, axloc=111, xlim=[-4,4], \n",
    "           ylim=[-4,4], zlim=[-4,4], xc=5, yc=5, zc=5):    \n",
    "    if fig is None:\n",
    "        fig = plt.figure(figsize=(12,9))\n",
    "    ax = fig.add_subplot(axloc, projection='3d')\n",
    "    colors = ('red', 'blue', 'green', 'yellow', 'cyan', 'black', 'purple', 'gray')\n",
    "    cmap = ListedColormap(colors[:len(np.unique(labels))])\n",
    "    ax.set_xlim(xlim)\n",
    "    ax.set_ylim(ylim)\n",
    "    ax.set_zlim(zlim)\n",
    "    if ds is not None:\n",
    "        if labels is not None:\n",
    "            ax.scatter(ds[:, 0], ds[:, 1], ds[:, 2], marker='.', \n",
    "                       alpha=1, lw=0, c=cmap(labels))\n",
    "        else:\n",
    "            ax.scatter(ds[:, 0], ds[:, 1], ds[:, 2], marker='.', \n",
    "                       alpha=1, lw=0)\n",
    "    \n",
    "    if comp is not None:\n",
    "        # add principal components here:\n",
    "        for i in np.arange(len(comp)):\n",
    "            ax.plot([-xc*comp[i, 0], xc*comp[i, 0]],\n",
    "                    [-yc*comp[i, 1], yc*comp[i, 1]],\n",
    "                    zs=[-zc*comp[i, 2], zc*comp[i, 2]])\n",
    "\n",
    "    return fig, ax"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X=FeatureArray3\n",
    "sc = StandardScaler() \n",
    "X_std = sc.fit_transform(X) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "X_std.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "pca = PCA()\n",
    "x_pca = pca.fit_transform(X_std)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "print(pca.components_.shape)\n",
    "print(x_pca.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "f, ax = plot3D(ds=x, comp=pca.components_, axloc=221)\n",
    "ax.set_title('PCA Components')\n",
    "ax.set_xlabel('X')\n",
    "ax.set_ylabel('Y')\n",
    "ax.set_zlabel('Z')\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "ax = f.add_subplot(222)\n",
    "ax.plot(np.cumsum(pca.explained_variance_ratio_), 'ro-')\n",
    "ax.plot(pca.explained_variance_ratio_, 'o-')\n",
    "ax.set_title(\"Variance explained\")\n",
    "ax.set_ylabel(\"variances\")\n",
    "ax.set_xlabel(\"Components kept\")\n",
    "ax.legend(['Cumulative variances explained', 'Explained variances'])\n",
    "\n",
    "plt.figure(figsize=(12, 9))\n",
    "\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "np.cumsum(pca.explained_variance_ratio_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#projected 12 leads\n",
    "for i in range(0,11):\n",
    "    plt.plot( x_pca[:300,i]) \n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Spectogram(converting 1D ECG signal to a 2D image)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtEAAAEWCAYAAACgzMuWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3XeclPW1x/HP2c6y9N5BigooCggaxd6jokaNSexGY6JJvDHF5KZojDcmMUZvrjFqNJaYWKNib7ErIAqi9N6ll4Vl28y5f8wzsMAuOzM7s1P2+3695rUzz/PMzJllmT175jznZ+6OiIiIiIjELi/dAYiIiIiIZBsl0SIiIiIicVISLSIiIiISJyXRIiIiIiJxUhItIiIiIhInJdEiIiIiInFSEi0iIiIiEicl0ZLR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zMSvofimxSlOvMVkgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 864x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, (ax1, ax2) = plt.subplots(1,2,figsize=(12,4))\n",
    "\n",
    "ax1.plot(beat1_12lead[1,:]); ax1.set_title('Raw EEG')\n",
    "ax2.specgram(beat1_12lead[1,:], Fs=DATA_SAMPLING_RATE); ax2.set_title('Spectrogram'); ax2.set_ylabel('Freq (Hz)');\n",
    "ax2.set_xlabel('Time (s)');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "f1, PSD = signal.periodogram(beat1_12lead[1,:], DATA_SAMPLING_RATE, 'flattop', scaling = 'density')\n",
    "fig, ax1 = plt.subplots(figsize = (15, 3))\n",
    "ax1.plot(f1, PSD, 'b')\n",
    "ax1.set(xlabel = 'Frequency [Hz]', xlim = [0, INPUT_BEAT_SIZE-1], xticks = np.arange(0, INPUT_BEAT_SIZE-1+5, 10))\n",
    "ax1.set(ylabel = 'PSD')\n",
    "plt.title('Power spectral density (PSD)', fontsize = 15)\n",
    "fig.savefig('physionet_ECG_PSD.png', bbox_inches = 'tight', dpi = 150)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def spectrogram(data, nperseg=64, noverlap=32, log_spectrogram = True):\n",
    "    fs = 300\n",
    "    f, t, Sxx = signal.spectrogram(data, fs=fs, nperseg=nperseg, noverlap=noverlap)\n",
    "    Sxx = np.transpose(Sxx,[0,2,1])\n",
    "    if log_spectrogram:\n",
    "        Sxx = abs(Sxx) # Make sure, all values are positive before taking log\n",
    "        mask = Sxx > 0 # We dont want to take the log of zero\n",
    "        Sxx[mask] = np.log(Sxx[mask])\n",
    "    return f, t, Sxx\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "ts_extended=beat1_12lead[1,:]\n",
    "\n",
    "# Convert ECG into spectrograms without and with log transform\n",
    "Sx = spectrogram(np.expand_dims(ts_extended, axis = 0), log_spectrogram = False)[2]\n",
    "Sx_log = spectrogram(np.expand_dims(ts_extended, axis = 0), log_spectrogram = True)[2]\n",
    "\n",
    "# Get the frequency and time axes\n",
    "f, t, _ = spectrogram(np.expand_dims(ts_extended, axis = 0), log_spectrogram = False) \n",
    "\n",
    "# Plot the spectrograms as images\n",
    "im_list = [Sx[0], Sx_log[0]]\n",
    "im_title = ['Spectrogram without log transform', 'Spectrogram with log transform']\n",
    "fig, ax_list = plt.subplots(1, 2, figsize = (15, 3))\n",
    "\n",
    "for i, ax in enumerate(ax_list):\n",
    "    \n",
    "    ax.imshow(np.transpose(im_list[i]), aspect = 'auto', cmap = 'jet')\n",
    "    ax.grid(False)\n",
    "    ax.invert_yaxis()\n",
    "    ax.set_title(im_title[i], fontsize = 12)\n",
    "    ax.set(ylim = [0, im_list[i].shape[1]], yticks = np.arange(0, im_list[i].shape[1] + 1, 5))\n",
    "    ax.set(xlabel = 'Time [s]', ylabel = 'Frequency [Hz]')\n",
    "    \n",
    "    # Replace axis labels with time from t array\n",
    "    xticks_array = np.arange(0, im_list[i].shape[0] + 1, 100)\n",
    "    ax.set(xlim = [0, im_list[i].shape[0]], xticks = xticks_array)\n",
    "    labels_new = [str(np.around(t[label], decimals = 1)) for label in xticks_array]\n",
    "    ax.set_xticklabels(labels_new)\n",
    "    ax.tick_params(axis = 'x',\n",
    "                   which = 'both',\n",
    "                   bottom = 'off')\n",
    "    \n",
    "    ax.tick_params(axis = 'y',\n",
    "                   which = 'both',\n",
    "                   left = 'off')\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "fig.savefig('physionet_ECG_spectrogram.png', bbox_inches = 'tight', dpi = 150)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### CNN Model on 12-lead ECG Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_X_loaded=np.loadtxt(root_path+'/nn-input/train_X.csv', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_X_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_X_loaded=train_X_loaded.reshape(train_X_loaded.shape[0],12,300)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_X_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "for i in range(0,11):\n",
    "    plt.plot( train_X_loaded[1000,i,:]) \n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_Y_loaded=np.loadtxt(root_path+'/nn-input/train_Y.csv', delimiter=',')\n",
    "train_Y_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_Y_loaded=train_Y_loaded[:,0]\n",
    "train_Y_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# le = preprocessing.LabelEncoder()\n",
    "# train_Y_loaded_encoded = le.fit_transform(train_Y_loaded)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_Y_loaded_encoded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_X_loaded=np.loadtxt(root_path+'/nn-input/test_X.csv', delimiter=',')\n",
    "test_X_loaded=test_X_loaded.reshape(test_X_loaded.shape[0],12,300)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_Y_loaded=np.loadtxt(root_path+'/nn-input/test_Y.csv', delimiter=',')\n",
    "test_Y_loaded=test_Y_loaded[:,0]\n",
    "# le = preprocessing.LabelEncoder()\n",
    "# test_Y_loaded_encoded = le.fit_transform(test_Y_loaded)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### VGG16 Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_Y_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "vgg16_model = keras.applications.vgg16.VGG16()\n",
    "vgg16_model.summary()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "from keras.models import Sequential\n",
    "type(vgg16_model) #This is a Keras Functional API need to convert to sequential\n",
    "# model = Sequential() #Iterate over the functional layers and add it as a stack\n",
    "model = tensorflow.keras.Sequential()\n",
    "for layer in vgg16_model.layers:\n",
    "    model.add(layer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "model.layers.pop()\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "for layer in model.layers: #Since the model is already trained with certain weights, we dont want to change it. Let it be the same\n",
    "    layer.trainable = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "model.add(Dense(num_of_people_in_data, activation='softmax', name='main_output_final'))\n",
    "model.compile(optimizer='adam', loss='categorical_crossentropy',metrics = ['accuracy'])\n",
    "callbacks = [EarlyStopping(monitor='val_loss', patience=8),\n",
    "             ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]\n",
    "\n",
    "history=model.fit(train_X_loaded, train_Y_loaded_encoded,epochs=40,callbacks=callbacks, batch_size=32,validation_data=(test_X_loaded,test_Y_loaded_encoded))\n",
    "model.load_weights('best_model.h5')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### CNN model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def network(X_train,y_train,X_test,y_test):\n",
    "    im_shape=(12,300,1)\n",
    "    inputs_cnn=Input(shape=(im_shape), name='inputs_cnn')\n",
    "    conv1_1=Convolution2D(32, (5,5), activation='relu', padding=\"same\", input_shape=im_shape)(inputs_cnn)\n",
    "    conv1_1=BatchNormalization()(conv1_1)\n",
    "    pool1=MaxPool2D(pool_size=(2,2))(conv1_1)\n",
    "    conv2_1=Convolution2D(64, (5,5), padding=\"same\", activation='relu')(pool1)\n",
    "    conv2_1=BatchNormalization()(conv2_1)\n",
    "    pool2=MaxPool2D(pool_size=(2,2))(conv2_1)\n",
    "    conv3_1=Convolution2D(128, (5,5), padding=\"same\", activation='relu')(pool2)\n",
    "    conv3_1=BatchNormalization()(conv3_1)\n",
    "    pool3=MaxPool2D(pool_size=(2,2))(conv3_1)\n",
    "#     conv4_1=Convolution2D(256, (5,5), padding=\"same\", activation='relu')(pool3)\n",
    "#     conv4_1=BatchNormalization()(conv4_1)\n",
    "#     pool4=MaxPool2D(pool_size=(2,2))(conv4_1)\n",
    "    flatten=Flatten()(pool3)\n",
    "    dense_end1 = Dense(128, activation='relu')(flatten)\n",
    "    dense_end2 = Dense(50, activation='relu')(dense_end1)\n",
    "    main_output = Dense(num_of_people_in_data, activation='softmax', name='main_output')(dense_end2)\n",
    "    \n",
    "    \n",
    "    model = Model(inputs= inputs_cnn, outputs=main_output)\n",
    "    model.compile(optimizer='adam', loss='sparse_categorical_crossentropy',metrics = ['sparse_categorical_accuracy'])\n",
    "    \n",
    "        \n",
    "\n",
    "    callbacks = [EarlyStopping(monitor='val_loss', patience=8),\n",
    "             ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]\n",
    "\n",
    "    history=model.fit(X_train, y_train,epochs=40,callbacks=callbacks, batch_size=32,validation_data=(X_test,y_test))\n",
    "    model.load_weights('best_model.h5')\n",
    "    return(model,history)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_Y_loaded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "x_train_reshaped = train_X_loaded.reshape((-1, 12, 300, 1))\n",
    "test_X_reshaped=test_X_loaded.reshape((-1, 12, 300, 1))\n",
    "test_Y_loaded_encoded=to_categorical(test_Y_loaded)\n",
    "train_Y_loaded_encoded=to_categorical(train_Y_loaded)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "le = preprocessing.LabelEncoder()\n",
    "le.fit(train_Y_loaded)\n",
    "train_Y_loaded_encoded = le.transform(train_Y_loaded)\n",
    "test_Y_loaded_encoded = le.transform(test_Y_loaded)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(121179,)"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_Y_loaded_encoded.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 121179 samples, validate on 22056 samples\n",
      "Epoch 1/40\n",
      "121152/121179 [============================>.] - ETA: 6s - loss: 5.7905 - sparse_categorical_accuracy: 0.1518 "
     ]
    }
   ],
   "source": [
    "model,history=network(x_train_reshaped,train_Y_loaded_encoded,test_X_reshaped,test_Y_loaded_encoded)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Conv1D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def network(X_train,y_train,X_test,y_test):\n",
    "    im_shape=(X_train.shape[1],X_train.shape[2])\n",
    "    inputs_cnn=Input(shape=(im_shape), name='inputs_cnn')\n",
    "    conv1_1=Convolution1D(64, (6), activation=tf.nn.relu, input_shape=im_shape)(inputs_cnn)\n",
    "    conv1_1=BatchNormalization()(conv1_1)\n",
    "    pool1=MaxPool1D(pool_size=(3), strides=(2), padding=\"same\")(conv1_1)\n",
    "    conv2_1=Convolution1D(64, (3), activation=tf.nn.relu, input_shape=im_shape)(pool1)\n",
    "    conv2_1=BatchNormalization()(conv2_1)\n",
    "    pool2=MaxPool1D(pool_size=(2), strides=(2), padding=\"same\")(conv2_1)\n",
    "    conv3_1=Convolution1D(64, (3), activation=tf.nn.relu, input_shape=im_shape)(pool2)\n",
    "    conv3_1=BatchNormalization()(conv3_1)\n",
    "    pool3=MaxPool1D(pool_size=(2), strides=(2), padding=\"same\")(conv3_1)\n",
    "\n",
    "    conv4_1 = Convolution1D(128, (5), activation=tf.nn.relu, input_shape=im_shape)(pool3)\n",
    "    conv4_1 = BatchNormalization()(conv4_1)\n",
    "    pool4 = MaxPool1D(pool_size=(2), strides=(2), padding=\"same\")(conv4_1)\n",
    "\n",
    "    conv5_1 = Convolution1D(128, (7), activation=tf.nn.relu, input_shape=im_shape)(pool4)\n",
    "    conv5_1 = BatchNormalization()(conv5_1)\n",
    "    pool5 = MaxPool1D(pool_size=(2), strides=(2), padding=\"same\")(conv5_1)\n",
    "\n",
    "    flatten=Flatten()(pool5)\n",
    "    dense_end1 = Dense(128, activation=tf.nn.relu)(flatten)\n",
    "    dense_end2 = Dense(64, activation=tf.nn.relu)(dense_end1)\n",
    "    main_output = Dense(num_of_people_in_data, activation=tf.nn.softmax, name='main_output')(dense_end2)\n",
    "    \n",
    "    \n",
    "    model = Model(inputs= inputs_cnn, outputs=main_output)\n",
    "    model.summary()\n",
    "    #model.compile(optimizer='adam', loss='categorical_crossentropy',metrics = ['accuracy'])\n",
    "    #model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])\n",
    "    model.compile(optimizer = tf.keras.optimizers.Adam(learning_rate=1e-4),\n",
    "    loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),\n",
    "    metrics = ['accuracy'])\n",
    "    \n",
    "    #callbacks = [EarlyStopping(monitor='val_loss', patience=8),\n",
    "     #        ModelCheckpoint(filepath='G:\\\\BioSigIdentification\\\\ECGData\\\\SXNBData\\\\best_model.h5', monitor='val_loss', save_best_only=True)]\n",
    "\n",
    "    #history=model.fit(X_train, y_train,epochs=40,callbacks=callbacks, batch_size=32,validation_data=(X_test,y_test))\n",
    "    history = model.fit(X_train, y_train, epochs=80, batch_size=64,\n",
    "                        validation_data=(X_test, y_test))\n",
    "    #model.load_weights('G:\\\\BioSigIdentification\\\\ECGData\\\\SXNBData\\\\best_model.h5')\n",
    "    return(model,history)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "Reshape_size = [X_test.shape[1],1]\n",
    "model = network(Reshape_size, num_of_people_in_data)\n",
    "model.summary()\n",
    "\n",
    "val_dataset = tf.data.Dataset.from_tensor_slices((X_test, y_test))\n",
    "val_dataset = val_dataset.batch(128)\n",
    "batch_size = 64\n",
    "train_dataset = tf.data.Dataset.from_tensor_slices((X_train, y_train))\n",
    "train_dataset = train_dataset.batch(batch_size)\n",
    "train_dataset = train_dataset.repeat()\n",
    "train_dataset = train_dataset.shuffle(buffer_size=y_train.shape[0], reshuffle_each_iteration=True)\n",
    "\n",
    "imodel=0\n",
    "model.fit(train_dataset, epochs=1, steps_per_epoch=math.ceil(y_train.shape[0] / (batch_size)), validation_data=val_dataset)#, callbacks=callbacks)\n",
    "\n",
    "model.fit(X_train, y_train, epochs=1, batch_size=64, validation_data=(X_test, y_test))\n",
    "\n",
    "model,history=network(X_train,y_train,X_test,y_test)\n",
    "evaluate_model(history,X_test,y_test,model)\n",
    "y_pred=model.predict(X_test)\n",
    "\n",
    "#predicted class vs actual, some examples\n",
    "print(list(y_pred.argmax(axis=1)[1:20]))\n",
    "print(list(target_test[1:20]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "model = Sequential()\n",
    "model.add(Conv1D(filters=64, kernel_size=2, activation='relu', input_shape=(12, 300)))\n",
    "model.add(MaxPooling1D(pool_size=2))\n",
    "model.add(Flatten())\n",
    "model.add(Dense(50, activation='relu'))\n",
    "model.add(Dense(1))\n",
    "model.compile(optimizer='adam', loss='mse')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "FeatureArray=np.loadtxt('G:/BioSigIdentification/ECGData/SXNBData/FeatureArray.csv', delimiter=',')\n",
    "le = preprocessing.LabelEncoder()\n",
    "Counter(FeatureArray[:,300])\n",
    "CountDF = pd.Series(Counter(FeatureArray[:,300]))\n",
    "CountDF = CountDF.sort_values()\n",
    "Over100Index = CountDF.loc[CountDF>5].index\n",
    "FeatureArray = FeatureArray[np.isin(FeatureArray[:,300], Over100Index),:]\n",
    "\n",
    "FeatureArray[:,300] = le.fit_transform(FeatureArray[:,300])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def evaluate_model(history,X_test,y_test,model):\n",
    "    scores = model.evaluate((X_test),y_test, verbose=0)\n",
    "    print(\"Accuracy: %.2f%%\" % (scores[1]*100))\n",
    "    \n",
    "    print(history)\n",
    "    fig1, ax_acc = plt.subplots()\n",
    "    plt.plot(history.history['accuracy'])\n",
    "    plt.plot(history.history['val_accuracy'])\n",
    "    plt.xlabel('Epoch')\n",
    "    plt.ylabel('Accuracy')\n",
    "    plt.title('Model - Accuracy')\n",
    "    plt.legend(['Training', 'Validation'], loc='lower right')\n",
    "    plt.show()\n",
    "    \n",
    "    fig2, ax_loss = plt.subplots()\n",
    "    plt.xlabel('Epoch')\n",
    "    plt.ylabel('Loss')\n",
    "    plt.title('Model- Loss')\n",
    "    plt.legend(['Training', 'Validation'], loc='upper right')\n",
    "    plt.plot(history.history['loss'])\n",
    "    plt.plot(history.history['val_loss'])\n",
    "    plt.show()\n",
    "    \n",
    "    y_true=[]\n",
    "    for element in y_test:\n",
    "        y_true.append(np.argmax(element))\n",
    "    prediction_proba=model.predict(X_test)\n",
    "    prediction=np.argmax(prediction_proba,axis=1)\n",
    "    cnf_matrix = confusion_matrix(y_true, prediction)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "\n",
    "def network2(X_train,y_train,X_test,y_test):\n",
    "    im_shape=(12,300,1)\n",
    "    inputs_cnn=Input(shape=(im_shape), name='inputs_cnn')\n",
    "    conv1_1=Convolution2D(32, (5,5), activation='relu', padding=\"same\", input_shape=im_shape)(inputs_cnn)\n",
    "    conv1_1=BatchNormalization()(conv1_1)\n",
    "    pool1=MaxPool2D(pool_size=(2,2))(conv1_1)\n",
    "    conv2_1=Convolution2D(64, (5,5), padding=\"same\", activation='relu')(pool1)\n",
    "    conv2_1=BatchNormalization()(conv2_1)\n",
    "    pool2=MaxPool2D(pool_size=(2,2))(conv2_1)\n",
    "    conv3_1=Convolution2D(128, (5,5), padding=\"same\", activation='relu')(pool2)\n",
    "    conv3_1=BatchNormalization()(conv3_1)\n",
    "    pool3=MaxPool2D(pool_size=(2,2))(conv3_1)\n",
    "    conv4_1=Convolution2D(256, (5,5), padding=\"same\", activation='relu',data_format='channels_first')(pool3)\n",
    "    conv4_1=BatchNormalization()(conv4_1)\n",
    "    pool4=MaxPool2D(pool_size=(2,2))(conv4_1)\n",
    "    conv5_1=Convolution2D(512, (5,5), padding=\"same\", activation='relu',data_format='channels_first')(pool4)\n",
    "    conv5_1=BatchNormalization()(conv5_1)\n",
    "    pool5=MaxPool2D(pool_size=(2,2))(conv5_1)\n",
    "    flatten=Flatten()(pool5)\n",
    "    dense_end1 = Dense(512, activation='relu')(flatten)\n",
    "    dense_end2 = Dense(200, activation='relu')(dense_end1)\n",
    "    main_output = Dense(num_of_people_in_data, activation='softmax', name='main_output')(dense_end2)\n",
    "    \n",
    "    \n",
    "    model = Model(inputs= inputs_cnn, outputs=main_output)\n",
    "    model.compile(optimizer='adam', loss='sparse_categorical_crossentropy',metrics = ['sparse_categorical_accuracy'])\n",
    "    \n",
    "        \n",
    "\n",
    "    callbacks = [EarlyStopping(monitor='val_loss', patience=8),\n",
    "             ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]\n",
    "\n",
    "    history=model.fit(X_train, y_train,epochs=40,callbacks=callbacks, batch_size=32,validation_data=(X_test,y_test))\n",
    "    model.load_weights('best_model.h5')\n",
    "    return(model,history)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Residual Network\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### LSTM\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### convolutional neural network plus LSTM layers and an attention module\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### detecting the disease first and then narrowing the search to that group\n",
    "this will be a multi-level bayesian risk calculation. first the accuracy of diease detection for each disease and then the accuracy of the detection in that group. then we generalize these results to all human population. how sure we are about the identification result, how much noise should we add to bring the accuracy say to 80% or 70%"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " #### differential privacy \n",
    " rarity of disease(we can get from other sources how many people in world have that condition) and then the noise needed to make it epsilon differentially private (how to caculate this for ecg input to neural network while keeping the information in the ECG data). for publishing an aggregated result. what diseases are harder to do a privacy-preserving analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "output_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# trainX = np.loadtxt(output_path+'/trainX.csv', delimiter=',')\n",
    "# testX = np.loadtxt(output_path+'/testX.csv', delimiter=',')\n",
    "\n",
    "# trainY = np.loadtxt(output_path+'/trainY.csv', delimiter=',')\n",
    "# testY = np.loadtxt(output_path+'/testY.csv', delimiter=',')\n",
    "\n",
    "train_diagnosis = pd.read_csv(output_path+'/train-diagnosis.csv', delimiter=':')\n",
    "test_diagnosis =  pd.read_csv(output_path+'/test-diagnosis.csv', delimiter=':')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'testX' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-8-b0e91bff6c47>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtestX\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m: name 'testX' is not defined"
     ]
    }
   ],
   "source": [
    "testX.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(479595, 2)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_diagnosis.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_daignosis=pd.read_csv(output_path+'/test-diagnosis.csv', delimiter=':',names=['id','diagnosis'])\n",
    "test_daignosis.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "test_daignosis['diagnosis']=test_daignosis['diagnosis'].apply(lambda x: x.strip('][').split(', ') )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 18 entries, 0 to 17\n",
      "Data columns (total 2 columns):\n",
      " #   Column     Non-Null Count  Dtype  \n",
      "---  ------     --------------  -----  \n",
      " 0   id         18 non-null     float64\n",
      " 1   diagnosis  18 non-null     object \n",
      "dtypes: float64(1), object(1)\n",
      "memory usage: 416.0+ bytes\n"
     ]
    }
   ],
   "source": [
    "test_daignosis.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(test_daignosis['diagnosis'][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def unnest(df, col, reset_index=False):\n",
    "    import pandas as pd\n",
    "    col_flat = pd.DataFrame([[i, x] \n",
    "                       for i, y in df[col].apply(list).iteritems() \n",
    "                           for x in y], columns=['I', col])\n",
    "    col_flat = col_flat.set_index('I')\n",
    "    df = df.drop(col, 1)\n",
    "    df = df.merge(col_flat, left_index=True, right_index=True)\n",
    "    if reset_index:\n",
    "        df = df.reset_index(drop=True)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "flattened_diagnosis = unnest(test_daignosis, 'diagnosis')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diagnosis</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2269.0</td>\n",
       "      <td>'Ventricular_Escape_Beat'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2269.0</td>\n",
       "      <td>'Ventricular_Escape_Beat'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2269.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2269.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2317.0</td>\n",
       "      <td>'Atrial_Fibrillation'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2317.0</td>\n",
       "      <td>'Atrial_Fibrillation'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2317.0</td>\n",
       "      <td>'Atrial_Fibrillation'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2317.0</td>\n",
       "      <td>'Atrial_Fibrillation'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'1AVBlock'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Atrial_Premature_Beat'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Atrial_Rhythm'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Pacemaker_ECG'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Pacemaker_ECG'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'1AVBlock'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Atrial_Premature_Beat'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Atrial_Rhythm'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Pacemaker_ECG'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1052.0</td>\n",
       "      <td>'Pacemaker_ECG'</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        id                   diagnosis\n",
       "0   1673.0         'Sinus_Tachycardia'\n",
       "1   1673.0         'Sinus_Tachycardia'\n",
       "2   1673.0         'Sinus_Tachycardia'\n",
       "3   1673.0         'Sinus_Tachycardia'\n",
       "4   1673.0         'Sinus_Tachycardia'\n",
       "5   1673.0         'Sinus_Tachycardia'\n",
       "6   1673.0         'Sinus_Tachycardia'\n",
       "7   1673.0         'Sinus_Tachycardia'\n",
       "8   2269.0   'Ventricular_Escape_Beat'\n",
       "9   2269.0   'Ventricular_Escape_Beat'\n",
       "10  2269.0         'Sinus_Tachycardia'\n",
       "11  2269.0         'Sinus_Tachycardia'\n",
       "12  2317.0       'Atrial_Fibrillation'\n",
       "13  2317.0       'Atrial_Fibrillation'\n",
       "14  2317.0       'Atrial_Fibrillation'\n",
       "15  2317.0       'Atrial_Fibrillation'\n",
       "16  1052.0                  '1AVBlock'\n",
       "16  1052.0     'Atrial_Premature_Beat'\n",
       "16  1052.0             'Atrial_Rhythm'\n",
       "16  1052.0             'Pacemaker_ECG'\n",
       "16  1052.0             'Pacemaker_ECG'\n",
       "17  1052.0                  '1AVBlock'\n",
       "17  1052.0     'Atrial_Premature_Beat'\n",
       "17  1052.0             'Atrial_Rhythm'\n",
       "17  1052.0             'Pacemaker_ECG'\n",
       "17  1052.0             'Pacemaker_ECG'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "flattened_diagnosis\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "id                                                        1052\n",
      "diagnosis    ['1AVBlock', 'Atrial_Premature_Beat', 'Atrial_...\n",
      "Name: 16, dtype: object\n"
     ]
    }
   ],
   "source": [
    "print(test_daignosis.iloc[16]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>diagnosis</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia']</th>\n",
       "      <td>576</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation']</th>\n",
       "      <td>363</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Rhythm']</th>\n",
       "      <td>257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Tachycardia']</th>\n",
       "      <td>195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Flutter']</th>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Irregularity']</th>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','Pacemaker_ECG','Pacemaker_ECG']</th>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','Pacemaker_ECG']</th>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Ventricular_Fibrillation']</th>\n",
       "      <td>53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','PVC']</th>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    count\n",
       "diagnosis                                                \n",
       "['Sinus_Bradycardia']                                 576\n",
       "['Atrial_Fibrillation']                               363\n",
       "['Sinus_Rhythm']                                      257\n",
       "['Sinus_Tachycardia']                                 195\n",
       "['Atrial_Flutter']                                     75\n",
       "['Sinus_Irregularity']                                 71\n",
       "['Atrial_Fibrillation','Pacemaker_ECG','Pacemak...     68\n",
       "['Atrial_Fibrillation','Pacemaker_ECG']                55\n",
       "['Ventricular_Fibrillation']                           53\n",
       "['Atrial_Fibrillation','PVC']                          52"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# file_path='/Users/aring/Desktop/ECG-identification/missidentification-per-disease.csv'\n",
    "file_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all/missidentification-per-joint-disease.csv'\n",
    "\n",
    "by_disease = (pd.read_csv(file_path)).set_index('diagnosis').sort_values(by=['count'],ascending=False)\n",
    "by_disease.head(n=10)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# by_disease.to_csv('/Users/aring/Desktop/ECG-identification/missidentification-per-disease-sorted.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>diagnosis</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia']</th>\n",
       "      <td>24908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Rhythm']</th>\n",
       "      <td>13843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Tachycardia']</th>\n",
       "      <td>10389</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation']</th>\n",
       "      <td>8821</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Irregularity']</th>\n",
       "      <td>3405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Flutter']</th>\n",
       "      <td>1957</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['1AVBlock','Sinus_Bradycardia']</th>\n",
       "      <td>978</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia','Sinus_Irregularity']</th>\n",
       "      <td>852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['SVT']</th>\n",
       "      <td>851</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','PVC']</th>\n",
       "      <td>670</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            count\n",
       "diagnosis                                        \n",
       "['Sinus_Bradycardia']                       24908\n",
       "['Sinus_Rhythm']                            13843\n",
       "['Sinus_Tachycardia']                       10389\n",
       "['Atrial_Fibrillation']                      8821\n",
       "['Sinus_Irregularity']                       3405\n",
       "['Atrial_Flutter']                           1957\n",
       "['1AVBlock','Sinus_Bradycardia']              978\n",
       "['Sinus_Bradycardia','Sinus_Irregularity']    852\n",
       "['SVT']                                       851\n",
       "['Atrial_Fibrillation','PVC']                 670"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# file_path='/Users/aring/Desktop/ECG-identification/success-identification-per-disease.csv'\n",
    "file_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all/success-identification-per-joint-disease.csv'\n",
    "\n",
    "coorrect_classifications = (pd.read_csv(file_path)).set_index('diagnosis').sort_values(by=['count'],ascending=False)\n",
    "coorrect_classifications.head(n=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count_x</th>\n",
       "      <th>count_y</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>diagnosis</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia']</th>\n",
       "      <td>24908</td>\n",
       "      <td>576</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Rhythm']</th>\n",
       "      <td>13843</td>\n",
       "      <td>257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Tachycardia']</th>\n",
       "      <td>10389</td>\n",
       "      <td>195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation']</th>\n",
       "      <td>8821</td>\n",
       "      <td>363</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Irregularity']</th>\n",
       "      <td>3405</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Flutter']</th>\n",
       "      <td>1957</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['1AVBlock','Sinus_Bradycardia']</th>\n",
       "      <td>978</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia','Sinus_Irregularity']</th>\n",
       "      <td>852</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['SVT']</th>\n",
       "      <td>851</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','PVC']</th>\n",
       "      <td>670</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            count_x  count_y\n",
       "diagnosis                                                   \n",
       "['Sinus_Bradycardia']                         24908      576\n",
       "['Sinus_Rhythm']                              13843      257\n",
       "['Sinus_Tachycardia']                         10389      195\n",
       "['Atrial_Fibrillation']                        8821      363\n",
       "['Sinus_Irregularity']                         3405       71\n",
       "['Atrial_Flutter']                             1957       75\n",
       "['1AVBlock','Sinus_Bradycardia']                978       30\n",
       "['Sinus_Bradycardia','Sinus_Irregularity']      852       20\n",
       "['SVT']                                         851       19\n",
       "['Atrial_Fibrillation','PVC']                   670       52"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_classifications=coorrect_classifications.merge(by_disease, left_on='diagnosis', right_on='diagnosis')\n",
    "all_classifications.head(n=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "all_classifications['sum_classifications']=all_classifications['count_x']+all_classifications['count_y']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count_x</th>\n",
       "      <th>count_y</th>\n",
       "      <th>sum_classifications</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>diagnosis</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia']</th>\n",
       "      <td>24908</td>\n",
       "      <td>576</td>\n",
       "      <td>25484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Rhythm']</th>\n",
       "      <td>13843</td>\n",
       "      <td>257</td>\n",
       "      <td>14100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Tachycardia']</th>\n",
       "      <td>10389</td>\n",
       "      <td>195</td>\n",
       "      <td>10584</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation']</th>\n",
       "      <td>8821</td>\n",
       "      <td>363</td>\n",
       "      <td>9184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Irregularity']</th>\n",
       "      <td>3405</td>\n",
       "      <td>71</td>\n",
       "      <td>3476</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Flutter']</th>\n",
       "      <td>1957</td>\n",
       "      <td>75</td>\n",
       "      <td>2032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['1AVBlock','Sinus_Bradycardia']</th>\n",
       "      <td>978</td>\n",
       "      <td>30</td>\n",
       "      <td>1008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Sinus_Bradycardia','Sinus_Irregularity']</th>\n",
       "      <td>852</td>\n",
       "      <td>20</td>\n",
       "      <td>872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['SVT']</th>\n",
       "      <td>851</td>\n",
       "      <td>19</td>\n",
       "      <td>870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['Atrial_Fibrillation','PVC']</th>\n",
       "      <td>670</td>\n",
       "      <td>52</td>\n",
       "      <td>722</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            count_x  count_y  \\\n",
       "diagnosis                                                      \n",
       "['Sinus_Bradycardia']                         24908      576   \n",
       "['Sinus_Rhythm']                              13843      257   \n",
       "['Sinus_Tachycardia']                         10389      195   \n",
       "['Atrial_Fibrillation']                        8821      363   \n",
       "['Sinus_Irregularity']                         3405       71   \n",
       "['Atrial_Flutter']                             1957       75   \n",
       "['1AVBlock','Sinus_Bradycardia']                978       30   \n",
       "['Sinus_Bradycardia','Sinus_Irregularity']      852       20   \n",
       "['SVT']                                         851       19   \n",
       "['Atrial_Fibrillation','PVC']                   670       52   \n",
       "\n",
       "                                            sum_classifications  \n",
       "diagnosis                                                        \n",
       "['Sinus_Bradycardia']                                     25484  \n",
       "['Sinus_Rhythm']                                          14100  \n",
       "['Sinus_Tachycardia']                                     10584  \n",
       "['Atrial_Fibrillation']                                    9184  \n",
       "['Sinus_Irregularity']                                     3476  \n",
       "['Atrial_Flutter']                                         2032  \n",
       "['1AVBlock','Sinus_Bradycardia']                           1008  \n",
       "['Sinus_Bradycardia','Sinus_Irregularity']                  872  \n",
       "['SVT']                                                     870  \n",
       "['Atrial_Fibrillation','PVC']                               722  "
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_classifications.head(n=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "all_classifications['missclassificsation_ratio']=all_classifications['count_y']/all_classifications['sum_classifications']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_d48c19cc_62a5_11eb_b0b4_f018981e47a7 caption {\n",
       "          text-align: center;\n",
       "          color: red;\n",
       "          font-size: 16px;\n",
       "    }</style><table id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7\" ><caption>Missclassifications ratio (the number of heart beats classified correctly vs incorrectly)</caption><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >number of heart beats</th>        <th class=\"col_heading level0 col1\" >missclassificsation ratio</th>    </tr>    <tr>        <th class=\"index_name level0\" >diagnosis</th>        <th class=\"blank\" ></th>        <th class=\"blank\" ></th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row0\" class=\"row_heading level0 row0\" >['Ventricular_Fibrillation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row0_col0\" class=\"data row0 col0\" >114</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row0_col1\" class=\"data row0 col1\" >0.464912</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row1\" class=\"row_heading level0 row1\" >['Ventricular_Escape_Beat']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row1_col0\" class=\"data row1 col0\" >114</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row1_col1\" class=\"data row1 col1\" >0.201754</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row2\" class=\"row_heading level0 row2\" >['PVC','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row2_col0\" class=\"data row2 col0\" >268</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row2_col1\" class=\"data row2 col1\" >0.149254</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row3\" class=\"row_heading level0 row3\" >['Atrial_Fibrillation','Pacemaker_ECG','Pacemaker_ECG']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row3_col0\" class=\"data row3 col0\" >456</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row3_col1\" class=\"data row3 col1\" >0.149123</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row4\" class=\"row_heading level0 row4\" >['Atrial_Fibrillation','Pacemaker_ECG']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row4_col0\" class=\"data row4 col0\" >396</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row4_col1\" class=\"data row4 col1\" >0.138889</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row5\" class=\"row_heading level0 row5\" >['Atrial_Flutter','Pacemaker_ECG']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row5_col0\" class=\"data row5 col0\" >174</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row5_col1\" class=\"data row5 col1\" >0.126437</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row6\" class=\"row_heading level0 row6\" >['PVC','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row6_col0\" class=\"data row6 col0\" >102</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row6_col1\" class=\"data row6 col1\" >0.098039</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row7\" class=\"row_heading level0 row7\" >['Atrial_FibrillationAberrant_Ventricular_Conduction']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row7_col0\" class=\"data row7 col0\" >146</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row7_col1\" class=\"data row7 col1\" >0.089041</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row8\" class=\"row_heading level0 row8\" >['Atrial_Fibrillation','Intraventricular_Block']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row8_col0\" class=\"data row8 col0\" >158</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row8_col1\" class=\"data row8 col1\" >0.088608</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row9\" class=\"row_heading level0 row9\" >['PVC','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row9_col0\" class=\"data row9 col0\" >328</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row9_col1\" class=\"data row9 col1\" >0.082317</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row10\" class=\"row_heading level0 row10\" >['Atrial_Fibrillation','Counterclockwise_Rotation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row10_col0\" class=\"data row10 col0\" >146</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row10_col1\" class=\"data row10 col1\" >0.075342</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row11\" class=\"row_heading level0 row11\" >['Atrial_Fibrillation','PVC']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row11_col0\" class=\"data row11 col0\" >722</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row11_col1\" class=\"data row11 col1\" >0.072022</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row12\" class=\"row_heading level0 row12\" >['Aberrant_Ventricular_Conduction','Atrial_Fibrillation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row12_col0\" class=\"data row12 col0\" >588</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row12_col1\" class=\"data row12 col1\" >0.071429</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row13\" class=\"row_heading level0 row13\" >['RBBB','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row13_col0\" class=\"data row13 col0\" >140</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row13_col1\" class=\"data row13 col1\" >0.071429</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row14\" class=\"row_heading level0 row14\" >['Atrial_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row14_col0\" class=\"data row14 col0\" >128</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row14_col1\" class=\"data row14 col1\" >0.070312</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row15\" class=\"row_heading level0 row15\" >['Pacemaker_ECG']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row15_col0\" class=\"data row15 col0\" >300</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row15_col1\" class=\"data row15 col1\" >0.066667</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row16\" class=\"row_heading level0 row16\" >['Atrial_Fibrillation','Incomplete_RBBB']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row16_col0\" class=\"data row16 col0\" >162</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row16_col1\" class=\"data row16 col1\" >0.061728</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row17\" class=\"row_heading level0 row17\" >['Atrial_Fibrillation','Left_Axis_Deviation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row17_col0\" class=\"data row17 col0\" >474</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row17_col1\" class=\"data row17 col1\" >0.061181</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row18\" class=\"row_heading level0 row18\" >['Atrial_Fibrillation','Right_Axis_Deviation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row18_col0\" class=\"data row18 col0\" >278</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row18_col1\" class=\"data row18 col1\" >0.057554</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row19\" class=\"row_heading level0 row19\" >['Atrial_Premature_Beat','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row19_col0\" class=\"data row19 col0\" >550</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row19_col1\" class=\"data row19 col1\" >0.056364</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row20\" class=\"row_heading level0 row20\" >['VT']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row20_col0\" class=\"data row20 col0\" >126</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row20_col1\" class=\"data row20 col1\" >0.055556</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row21\" class=\"row_heading level0 row21\" >['Pacemaker_ECG','Pacemaker_ECG']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row21_col0\" class=\"data row21 col0\" >328</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row21_col1\" class=\"data row21 col1\" >0.054878</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row22\" class=\"row_heading level0 row22\" >['Atrial_Premature_Beat','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row22_col0\" class=\"data row22 col0\" >156</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row22_col1\" class=\"data row22 col1\" >0.051282</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row23\" class=\"row_heading level0 row23\" >['LongQT','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row23_col0\" class=\"data row23 col0\" >122</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row23_col1\" class=\"data row23 col1\" >0.049180</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row24\" class=\"row_heading level0 row24\" >['AVBlock','Atrial_Flutter']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row24_col0\" class=\"data row24 col0\" >150</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row24_col1\" class=\"data row24 col1\" >0.046667</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row25\" class=\"row_heading level0 row25\" >['Right_Axis_Deviation','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row25_col0\" class=\"data row25 col0\" >180</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row25_col1\" class=\"data row25 col1\" >0.044444</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row26\" class=\"row_heading level0 row26\" >['Atrial_Premature_Beat','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row26_col0\" class=\"data row26 col0\" >568</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row26_col1\" class=\"data row26 col1\" >0.042254</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row27\" class=\"row_heading level0 row27\" >['Sinus_Bradycardia','left_Anterior_Fascicular_Block']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row27_col0\" class=\"data row27 col0\" >120</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row27_col1\" class=\"data row27 col1\" >0.041667</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row28\" class=\"row_heading level0 row28\" >['Atrial_Flutter','Left_Axis_Deviation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row28_col0\" class=\"data row28 col0\" >122</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row28_col1\" class=\"data row28 col1\" >0.040984</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row29\" class=\"row_heading level0 row29\" >['Atrial_Fibrillation']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row29_col0\" class=\"data row29 col0\" >9184</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row29_col1\" class=\"data row29 col1\" >0.039525</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row30\" class=\"row_heading level0 row30\" >['Atrial_Fibrillation','RBBB']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row30_col0\" class=\"data row30 col0\" >152</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row30_col1\" class=\"data row30 col1\" >0.039474</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row31\" class=\"row_heading level0 row31\" >['Sinus_Bradycardia_and_Irregularity']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row31_col0\" class=\"data row31 col0\" >312</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row31_col1\" class=\"data row31 col1\" >0.038462</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row32\" class=\"row_heading level0 row32\" >['Atrial_Fibrillation','Complete_RBBB']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row32_col0\" class=\"data row32 col0\" >552</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row32_col1\" class=\"data row32 col1\" >0.038043</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row33\" class=\"row_heading level0 row33\" >['Atrial_Flutter']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row33_col0\" class=\"data row33 col0\" >2032</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row33_col1\" class=\"data row33 col1\" >0.036909</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row34\" class=\"row_heading level0 row34\" >['Left_Axis_Deviation','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row34_col0\" class=\"data row34 col0\" >612</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row34_col1\" class=\"data row34 col1\" >0.031046</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row35\" class=\"row_heading level0 row35\" >['Atrial_Flutter','Complete_RBBB']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row35_col0\" class=\"data row35 col0\" >230</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row35_col1\" class=\"data row35 col1\" >0.030435</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row36\" class=\"row_heading level0 row36\" >['1AVBlock','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row36_col0\" class=\"data row36 col0\" >1008</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row36_col1\" class=\"data row36 col1\" >0.029762</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row37\" class=\"row_heading level0 row37\" >['1AVBlock','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row37_col0\" class=\"data row37 col0\" >104</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row37_col1\" class=\"data row37 col1\" >0.028846</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row38\" class=\"row_heading level0 row38\" >['Left_Axis_Deviation','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row38_col0\" class=\"data row38 col0\" >278</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row38_col1\" class=\"data row38 col1\" >0.028777</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row39\" class=\"row_heading level0 row39\" >['Sinus_Bradycardia','Ventricular_Early_Repolarization']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row39_col0\" class=\"data row39 col0\" >598</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row39_col1\" class=\"data row39 col1\" >0.028428</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row40\" class=\"row_heading level0 row40\" >['Complete_RBBB','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row40_col0\" class=\"data row40 col0\" >144</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row40_col1\" class=\"data row40 col1\" >0.027778</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row41\" class=\"row_heading level0 row41\" >['Sinus_Irregularity','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row41_col0\" class=\"data row41 col0\" >368</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row41_col1\" class=\"data row41 col1\" >0.027174</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row42\" class=\"row_heading level0 row42\" >['Sinus_Bradycardia','Sinus_Irregularity']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row42_col0\" class=\"data row42 col0\" >872</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row42_col1\" class=\"data row42 col1\" >0.022936</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row43\" class=\"row_heading level0 row43\" >['Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row43_col0\" class=\"data row43 col0\" >25484</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row43_col1\" class=\"data row43 col1\" >0.022602</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row44\" class=\"row_heading level0 row44\" >['Intraventricular_Block','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row44_col0\" class=\"data row44 col0\" >134</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row44_col1\" class=\"data row44 col1\" >0.022388</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row45\" class=\"row_heading level0 row45\" >['SVT']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row45_col0\" class=\"data row45 col0\" >870</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row45_col1\" class=\"data row45 col1\" >0.021839</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row46\" class=\"row_heading level0 row46\" >['Sinus_Irregularity']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row46_col0\" class=\"data row46 col0\" >3476</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row46_col1\" class=\"data row46 col1\" >0.020426</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row47\" class=\"row_heading level0 row47\" >['Left_Axis_Deviation','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row47_col0\" class=\"data row47 col0\" >206</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row47_col1\" class=\"data row47 col1\" >0.019417</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row48\" class=\"row_heading level0 row48\" >['Complete_RBBB','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row48_col0\" class=\"data row48 col0\" >472</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row48_col1\" class=\"data row48 col1\" >0.019068</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row49\" class=\"row_heading level0 row49\" >['Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row49_col0\" class=\"data row49 col0\" >10584</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row49_col1\" class=\"data row49 col1\" >0.018424</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row50\" class=\"row_heading level0 row50\" >['Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row50_col0\" class=\"data row50 col0\" >14100</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row50_col1\" class=\"data row50 col1\" >0.018227</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row51\" class=\"row_heading level0 row51\" >['Right_Axis_Deviation','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row51_col0\" class=\"data row51 col0\" >420</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row51_col1\" class=\"data row51 col1\" >0.016667</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row52\" class=\"row_heading level0 row52\" >['Counterclockwise_Rotation','Sinus_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row52_col0\" class=\"data row52 col0\" >190</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row52_col1\" class=\"data row52 col1\" >0.015789</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row53\" class=\"row_heading level0 row53\" >['1AVBlock','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row53_col0\" class=\"data row53 col0\" >222</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row53_col1\" class=\"data row53 col1\" >0.013514</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row54\" class=\"row_heading level0 row54\" >['Counterclockwise_Rotation','Sinus_Bradycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row54_col0\" class=\"data row54 col0\" >332</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row54_col1\" class=\"data row54 col1\" >0.012048</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row55\" class=\"row_heading level0 row55\" >['Counterclockwise_Rotation','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row55_col0\" class=\"data row55 col0\" >170</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row55_col1\" class=\"data row55 col1\" >0.011765</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row56\" class=\"row_heading level0 row56\" >['Atrial_Rhythm']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row56_col0\" class=\"data row56 col0\" >298</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row56_col1\" class=\"data row56 col1\" >0.006711</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7level0_row57\" class=\"row_heading level0 row57\" >['Complete_RBBB','Sinus_Tachycardia']</th>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row57_col0\" class=\"data row57 col0\" >184</td>\n",
       "                        <td id=\"T_d48c19cc_62a5_11eb_b0b4_f018981e47a7row57_col1\" class=\"data row57 col1\" >0.005435</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x120754c88>"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_classifications=all_classifications.sort_values(by=['missclassificsation_ratio'],ascending=False)\n",
    "all_classifications.rename(columns = {'count_x':'correct_classification','count_y':'missclassification'}, inplace = True)\n",
    "# all_classifications.head(n=20)\n",
    "all_classifications_1=all_classifications[all_classifications['sum_classifications']>100]\n",
    "all_classifications_2=all_classifications_1.drop(['correct_classification','missclassification'], axis=1)\n",
    "all_classifications_2.rename(columns = {'sum_classifications':'number of heart beats','missclassificsation_ratio':'missclassificsation ratio'}, inplace = True)\n",
    "all_classifications_2.style.set_table_styles([{'selector': 'caption','props': [('text-align','center'),('color', 'red'),('font-size', '16px')]}]).set_caption('Missclassifications ratio (the number of heart beats classified correctly vs incorrectly)')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([''Ventricular_Fibrillation'', ''Ventricular_Escape_Beat'', ''3AVBlock'',\n",
       "       ''Junctional_Escape_Rhythm'', ''Pacemaker_ECG'', ''VT'', ''PVC'',\n",
       "       ''Junctional_Escape_Beat'',\n",
       "       ''Atrial_Premature_BeatAberrant_Ventricular_Conduction'',\n",
       "       ''Aberrant_Ventricular_Conduction'', ''LongQT'', ''WPW'',\n",
       "       ''Atrial_FibrillationAberrant_Ventricular_Conduction'',\n",
       "       ''Intraventricular_Block'', ''Atrial_Fibrillation'', ''AVBlock'',\n",
       "       ''RBBB'', ''Atrial_Premature_Beat'', ''Myocardial_Infarction'',\n",
       "       ''Bad_Data_Quality'', ''Clockwise_Rotation'', ''Incomplete_RBBB'',\n",
       "       ''left_Anterior_Fascicular_Block'', ''Atrial_Tachycardia'',\n",
       "       ''Complete_RBBB'', ''Atrial_Flutter'', ''Left_Axis_Deviation'',\n",
       "       ''Sinus_Bradycardia_and_Irregularity'', ''Missing_Lead'',\n",
       "       ''Complete_LBBB'', ''Right_Axis_Deviation'', ''1AVBlock'',\n",
       "       ''Ventricular_Early_Repolarization'', ''Counterclockwise_Rotation'',\n",
       "       ''Sinus_Bradycardia'', ''Sinus_Irregularity'', ''Sinus_Tachycardia'',\n",
       "       ''SVT'', ''Sinus_Rhythm'', ''Atrial_Rhythm''],\n",
       "      dtype='object', name='diagnosis')"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_classifications_2.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_classifications_2.to_csv('/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all/missidentification-per-joint-disease-morethan100samples-jointdiseases.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "correct_classification       82573.000000\n",
       "missclassification            2949.000000\n",
       "sum_classifications          85522.000000\n",
       "missclassificsation_ratio       87.084011\n",
       "dtype: float64"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_classifications.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 92.97485895278629\n"
     ]
    }
   ],
   "source": [
    "print('Accuracy: '+str(112719.00000/121236.00000*100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_classifications.to_csv('/Users/aring/Desktop/ECG-identification/missidentification-per-joint-disease-sorted2-full.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### for wavelet disease"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def unnest(df, col, reset_index=False):\n",
    "    import pandas as pd\n",
    "    col_flat = pd.DataFrame([[i, x]\n",
    "                             for i, y in df[col].apply(list).iteritems()\n",
    "                             for x in y], columns=['I', col])\n",
    "    col_flat = col_flat.set_index('I')\n",
    "    df = df.drop(col, 1)\n",
    "    df = df.merge(col_flat, left_index=True, right_index=True)\n",
    "    if reset_index:\n",
    "        df = df.reset_index(drop=True)\n",
    "    return df\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:6: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PatientID_encoded</th>\n",
       "      <th>diagnosis</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PatientID_encoded            diagnosis\n",
       "0             1673.0  'Sinus_Tachycardia'\n",
       "1             1673.0  'Sinus_Tachycardia'\n",
       "2             1673.0  'Sinus_Tachycardia'\n",
       "3             1673.0  'Sinus_Tachycardia'\n",
       "4             1673.0  'Sinus_Tachycardia'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all'\n",
    "\n",
    "train_daignosis=pd.read_csv(output_path+'/train-diagnosis.csv', delimiter=':',names=['PatientID_encoded','diagnosis'])\n",
    "train_daignosis['diagnosis']=train_daignosis['diagnosis'].apply(lambda x: x.strip('][').split(', ') )\n",
    "train_daignosis_singlediagnosis=train_daignosis.loc[train_daignosis['diagnosis'].apply(lambda x: len(x) ==1)]\n",
    "train_daignosis_singlediagnosis['diagnosis']=train_daignosis_singlediagnosis['diagnosis'].apply(lambda x: x[0] )\n",
    "train_daignosis_singlediagnosis=train_daignosis_singlediagnosis[(train_daignosis_singlediagnosis['diagnosis']== '\\'Sinus_Bradycardia\\'') \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'Sinus_Tachycardia\\'') \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'Sinus_Rhythm\\'' ) \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'Atrial_Fibrillation\\'') \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'Atrial_Flutter\\'') \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'Sinus_Irregularity\\'') \\\n",
    "                                                               | (train_daignosis_singlediagnosis['diagnosis']=='\\'SVT\\'')] \n",
    "\n",
    "# ,,,'',,,'] \n",
    "\n",
    "train_daignosis_singlediagnosis.head()\n",
    "# flattened_diagnosis = unnest(train_daignosis, 'diagnosis')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>diagnosis</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>'Sinus_Bradycardia'</td>\n",
       "      <td>84044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "      <td>78831</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>'Sinus_Rhythm'</td>\n",
       "      <td>68746</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>'Atrial_Fibrillation'</td>\n",
       "      <td>57809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>'Atrial_Flutter'</td>\n",
       "      <td>16470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>'Sinus_Irregularity'</td>\n",
       "      <td>16029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>'SVT'</td>\n",
       "      <td>10456</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               diagnosis  count\n",
       "3    'Sinus_Bradycardia'  84044\n",
       "6    'Sinus_Tachycardia'  78831\n",
       "5         'Sinus_Rhythm'  68746\n",
       "0  'Atrial_Fibrillation'  57809\n",
       "1       'Atrial_Flutter'  16470\n",
       "4   'Sinus_Irregularity'  16029\n",
       "2                  'SVT'  10456"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_daignosis_singlediagnosis_count=train_daignosis_singlediagnosis.groupby(['diagnosis']).size().reset_index(name='count')\n",
    "train_daignosis_singlediagnosis_count=train_daignosis_singlediagnosis_count.sort_values(by=['count'],ascending=False)\n",
    "train_daignosis_singlediagnosis_count.head(n=20)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PatientID_encoded</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>diagnosis</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>'Sinus_Tachycardia'</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PatientID_encoded       2       3       4       5       6       7       8  \\\n",
       "0             1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "1             1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "2             1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "3             1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "4             1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "\n",
       "        9      10      11      12            diagnosis  \n",
       "0  1673.0  1673.0  1673.0  1673.0  'Sinus_Tachycardia'  \n",
       "1  1673.0  1673.0  1673.0  1673.0  'Sinus_Tachycardia'  \n",
       "2  1673.0  1673.0  1673.0  1673.0  'Sinus_Tachycardia'  \n",
       "3  1673.0  1673.0  1673.0  1673.0  'Sinus_Tachycardia'  \n",
       "4  1673.0  1673.0  1673.0  1673.0  'Sinus_Tachycardia'  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all-small'\n",
    "train_Y_pd1=pd.read_csv(output_path+'/trainY.csv', delimiter=',',names=['PatientID_encoded','2','3','4','5','6','7','8','9','10','11','12'])\n",
    "train_disease_Y=train_Y_pd1.merge(train_daignosis_singlediagnosis, how='inner', on=['PatientID_encoded'])\n",
    "train_disease_Y.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train_gender_Y.shape(23508,)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "train_disease_Y=np.array(train_disease_Y['diagnosis'])\n",
    "print('train_gender_Y.shape'+str(train_disease_Y.shape))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "le = preprocessing.LabelEncoder()\n",
    "le.fit(train_disease_Y)\n",
    "train_y_encoded = le.transform(train_disease_Y)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1])"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_y_encoded[7000:8000]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### per disease analysis with multiple diagnisuis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 90618 entries, 0 to 90617\n",
      "Data columns (total 2 columns):\n",
      " #   Column     Non-Null Count  Dtype  \n",
      "---  ------     --------------  -----  \n",
      " 0   id         90618 non-null  float64\n",
      " 1   diagnosis  90618 non-null  object \n",
      "dtypes: float64(1), object(1)\n",
      "memory usage: 1.4+ MB\n"
     ]
    }
   ],
   "source": [
    "output_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all'\n",
    "test_daignosis=pd.read_csv(output_path+'/test-diagnosis.csv', delimiter=':',names=['id','diagnosis'])\n",
    "test_daignosis.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_daignosis['diagnosis']=test_daignosis['diagnosis'].apply(lambda x: x.strip('][').split(', ') )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "trainY = np.loadtxt(output_path+'/trainY.csv', delimiter=',')\n",
    "testY = np.loadtxt(output_path+'/testY.csv', delimiter=',')\n",
    "\n",
    "train_diagnosis = pd.read_csv(output_path+'/train-diagnosis.csv', delimiter=':')\n",
    "test_diagnosis =  pd.read_csv(output_path+'/test-diagnosis.csv', delimiter=':')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(479596, 12)"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainY.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 217,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(90618, 12)"
      ]
     },
     "execution_count": 217,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "testY.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0       1       2       3       4       5       6       7       8   \\\n",
       "0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "1  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "2  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "3  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "4  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "\n",
       "       9       10      11  \n",
       "0  1673.0  1673.0  1673.0  \n",
       "1  1673.0  1673.0  1673.0  \n",
       "2  1673.0  1673.0  1673.0  \n",
       "3  1673.0  1673.0  1673.0  \n",
       "4  1673.0  1673.0  1673.0  "
      ]
     },
     "execution_count": 227,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "testY = pd.read_csv(output_path+'/testY.csv',header=None)\n",
    "testY.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(39754,)"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "testY[testY.columns[0]].unique().shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "      <td>1673.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       0       1       2       3       4       5       6       7       8   \\\n",
       "0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "1  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "2  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "3  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "4  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0  1673.0   \n",
       "\n",
       "       9       10      11  \n",
       "0  1673.0  1673.0  1673.0  \n",
       "1  1673.0  1673.0  1673.0  \n",
       "2  1673.0  1673.0  1673.0  \n",
       "3  1673.0  1673.0  1673.0  \n",
       "4  1673.0  1673.0  1673.0  "
      ]
     },
     "execution_count": 230,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainY = pd.read_csv(output_path+'/testY.csv',header=None)\n",
    "trainY.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(39754,)"
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainY[trainY.columns[0]].unique().shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Colocations handled automatically by placer.\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "inputs_cnn (InputLayer)      (None, 12, 300, 1)        0         \n",
      "_________________________________________________________________\n",
      "conv2d (Conv2D)              (None, 12, 300, 32)       832       \n",
      "_________________________________________________________________\n",
      "batch_normalization (BatchNo (None, 12, 300, 32)       128       \n",
      "_________________________________________________________________\n",
      "max_pooling2d (MaxPooling2D) (None, 6, 150, 32)        0         \n",
      "_________________________________________________________________\n",
      "conv2d_1 (Conv2D)            (None, 6, 150, 64)        51264     \n",
      "_________________________________________________________________\n",
      "batch_normalization_1 (Batch (None, 6, 150, 64)        256       \n",
      "_________________________________________________________________\n",
      "max_pooling2d_1 (MaxPooling2 (None, 3, 75, 64)         0         \n",
      "_________________________________________________________________\n",
      "conv2d_2 (Conv2D)            (None, 3, 75, 128)        204928    \n",
      "_________________________________________________________________\n",
      "batch_normalization_2 (Batch (None, 3, 75, 128)        512       \n",
      "_________________________________________________________________\n",
      "max_pooling2d_2 (MaxPooling2 (None, 1, 37, 128)        0         \n",
      "_________________________________________________________________\n",
      "flatten (Flatten)            (None, 4736)              0         \n",
      "_________________________________________________________________\n",
      "dense (Dense)                (None, 128)               606336    \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 50)                6450      \n",
      "_________________________________________________________________\n",
      "main_output (Dense)          (None, 39754)             2027454   \n",
      "=================================================================\n",
      "Total params: 2,898,160\n",
      "Trainable params: 2,897,712\n",
      "Non-trainable params: 448\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "\n",
    "output_path='/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all'\n",
    "model = tf.keras.models.load_model('/Users/aring/IdeaProjects/ECG-biometric/src/100k-data/identification-model-29-Jan-2021-14-11-08.h5')\n",
    "\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 233,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "test_X_loaded=np.loadtxt(output_path+'/testX.csv', delimiter=',')\n",
    "test_X_loaded=test_X_loaded.reshape(test_X_loaded.shape[0],12,300)\n",
    "test_X_reshaped=test_X_loaded.reshape((-1, 12, 300, 1))\n",
    "\n",
    "test_Y_loaded=np.loadtxt(output_path+'/testY.csv', delimiter=',')\n",
    "test_Y_loaded=test_Y_loaded[:,0]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 236,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "le = preprocessing.LabelEncoder()\n",
    "le.fit(test_Y_loaded)\n",
    "test_y_encoded = le.transform(test_Y_loaded)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "prediction_proba=model.predict(test_X_reshaped[1900:2000])\n",
    "y_pred=np.argmax(prediction_proba,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 238,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1774, 1774, 1774, 1774, 1775, 1775, 1775, 1775, 1775, 1775, 1775,\n",
       "       1775, 1776, 1776, 1776, 1776, 1777, 1777, 1777, 1777, 1777, 1777,\n",
       "       1777, 1777, 1778, 1778, 1778, 1778, 1779, 1779, 1779, 1779, 1780,\n",
       "       1780, 1780, 1780, 1781, 1781, 1781, 1781, 1781, 1781, 1781, 1781,\n",
       "       1782, 1782, 1782, 1782, 1783, 1783, 1783, 1783, 1784, 1784, 1784,\n",
       "       1784, 1785, 1785, 1785, 1785, 1786, 1786, 1786, 1786, 1787, 1787,\n",
       "       1787, 1787, 1788, 1788, 1788,  963, 1789, 1789, 1789, 1789, 1789,\n",
       "       1789, 1790, 1790, 1790, 1790, 1791, 1791, 1791, 1791, 1791, 1791,\n",
       "       1792, 1792, 1792, 1792, 1794, 1794, 1794, 1794, 1795, 1795, 1795,\n",
       "       1795])"
      ]
     },
     "execution_count": 238,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 267,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([18479., 18479., 28134., 28134., 17100., 17100., 12205., 12205.,\n",
       "        6710.,  6710.])"
      ]
     },
     "execution_count": 267,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_Y_loaded[20000:20010]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 240,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1774, 1774, 1774, 1774, 1775, 1775, 1775, 1775, 1775, 1775, 1775,\n",
       "       1775, 1776, 1776, 1776, 1776, 1777, 1777, 1777, 1777, 1777, 1777,\n",
       "       1777, 1777, 1778, 1778, 1778, 1778, 1779, 1779, 1779, 1779, 1780,\n",
       "       1780, 1780, 1780, 1781, 1781, 1781, 1781, 1781, 1781, 1781, 1781,\n",
       "       1782, 1782, 1782, 1782, 1783, 1783, 1783, 1783, 1784, 1784, 1784,\n",
       "       1784, 1785, 1785, 1785, 1785, 1786, 1786, 1786, 1786, 1787, 1787,\n",
       "       1787, 1787, 1788, 1788, 1788, 1788, 1789, 1789, 1789, 1789, 1789,\n",
       "       1789, 1790, 1790, 1790, 1790, 1791, 1791, 1791, 1791, 1791, 1791,\n",
       "       1792, 1792, 1792, 1792, 1794, 1794, 1794, 1794, 1795, 1795, 1795,\n",
       "       1795])"
      ]
     },
     "execution_count": 240,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_y_encoded[1900:2000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1673, 1673, 1673, 1673, 1673, 1673, 1673, 2269, 2269])"
      ]
     },
     "execution_count": 243,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_y_encoded[1:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 244,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-43.56822153, -43.65241178, -43.58420697, ..., -36.22191282,\n",
       "        -44.13964742, -50.71336307],\n",
       "       [-18.54799982, -18.34301778, -18.16275296, ..., -14.39115566,\n",
       "        -19.66058556, -23.73713324],\n",
       "       [-23.05896018, -23.22134898, -23.27937123, ..., -24.62377476,\n",
       "        -27.00507438, -29.1197035 ],\n",
       "       ...,\n",
       "       [-37.53913221, -36.78074144, -35.89343154, ...,   7.61181495,\n",
       "          0.38304755,  -6.58461409],\n",
       "       [-44.12745531, -43.71700942, -43.15276823, ...,  -5.75617846,\n",
       "        -14.4379969 , -22.4293814 ],\n",
       "       [-33.81346293, -33.32160711, -32.79545582, ...,  -5.18918585,\n",
       "        -15.08537514, -23.61416562]])"
      ]
     },
     "execution_count": 244,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-23.99319613, -24.14439818, -24.3775829 , ...,  58.02249617,\n",
       "         53.47519147,  48.22875833],\n",
       "       [-13.74983013, -13.5726973 , -13.45991954, ...,  45.21527921,\n",
       "         47.09231862,  48.5282775 ],\n",
       "       [ -9.26142542,  -9.52713726,  -9.82349786, ...,   7.89309745,\n",
       "          3.59151835,  -0.42299714],\n",
       "       ...,\n",
       "       [-21.94677685, -20.77877298, -19.54159061, ...,  27.48488268,\n",
       "         24.20602162,  20.7503584 ],\n",
       "       [ 40.87287104,  41.94738829,  42.62685431, ...,  36.422045  ,\n",
       "         33.56118143,  30.54728302],\n",
       "       [-37.60810328, -37.57898829, -37.67783094, ...,  46.05780887,\n",
       "         43.39851599,  40.24734379]])"
      ]
     },
     "execution_count": 245,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-22.54382959, -22.44208677, -22.50172787, ...,  66.71483815,\n",
       "         63.69171856,  59.61342579],\n",
       "       [-13.38541312, -13.49601103, -13.61176132, ...,  40.77057966,\n",
       "         43.1790866 ,  45.15154814],\n",
       "       [ -8.52174301,  -8.42293626,  -8.40946418, ...,  21.85917915,\n",
       "         17.42712494,  12.79770305],\n",
       "       ...,\n",
       "       [-22.38042667, -21.27919444, -20.2270996 , ...,  19.18217193,\n",
       "         16.74020483,  13.66551456],\n",
       "       [-11.85382741, -11.11511973, -10.46860795, ...,  49.56688935,\n",
       "         47.41497939,  44.51705891],\n",
       "       [-23.24887119, -21.81436057, -20.41954817, ...,  45.14207123,\n",
       "         44.41814102,  42.81447564]])"
      ]
     },
     "execution_count": 246,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(12, 300)"
      ]
     },
     "execution_count": 263,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[5].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 248,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-19.79100658, -20.49180146, -21.24256473, ...,  58.45917371,\n",
       "         58.6872708 ,  58.57286644],\n",
       "       [-13.40139594, -13.6060606 , -13.77317286, ...,  24.03852874,\n",
       "         26.81176294,  29.26703761],\n",
       "       [ -8.67680832,  -9.20606775,  -9.73608188, ...,  38.38925306,\n",
       "         35.65402267,  32.70294462],\n",
       "       ...,\n",
       "       [-17.8266521 , -17.67294632, -17.52533595, ...,  16.96362885,\n",
       "         17.8836383 ,  19.21440161],\n",
       "       [-22.18595738, -22.05782431, -21.93059764, ...,  42.3804562 ,\n",
       "         45.89375081,  48.86908134],\n",
       "       [-19.03163045, -19.12884262, -19.21084442, ...,  35.68450689,\n",
       "         39.90590672,  43.76098808]])"
      ]
     },
     "execution_count": 248,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-27.3588809 , -27.31530588, -27.27141187, ...,  61.0907511 ,\n",
       "         54.4864678 ,  46.98093839],\n",
       "       [-11.26858897, -11.58318425, -11.83827426, ...,  45.32148861,\n",
       "         44.96743507,  43.47242913],\n",
       "       [-15.23908012, -15.02753465, -14.92876932, ...,  10.21888586,\n",
       "          6.13450318,   2.23427709],\n",
       "       ...,\n",
       "       [ -7.79985669,  -6.97413072,  -6.21047928, ...,  23.97232881,\n",
       "         22.23628538,  19.68413194],\n",
       "       [-10.50285139, -10.13076335,  -9.72609576, ...,  36.61706857,\n",
       "         33.97838172,  30.67540369],\n",
       "       [ -8.35581323,  -8.22594058,  -8.07606979, ...,  39.3818564 ,\n",
       "         36.82451814,  33.47003526]])"
      ]
     },
     "execution_count": 249,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 251,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-45.36546116, -45.51280284, -45.6220154 , ..., -15.71604097,\n",
       "        -24.45741329, -32.91954689],\n",
       "       [-18.97699683, -18.82029898, -18.6863727 , ...,   1.23090654,\n",
       "         -4.82214052, -10.58595393],\n",
       "       [-25.19990311, -25.44751007, -25.60736922, ..., -14.59709533,\n",
       "        -17.08401887, -19.61600674],\n",
       "       ...,\n",
       "       [-63.9163802 , -60.92650638, -57.98404877, ...,   5.21489866,\n",
       "          0.43582494,  -5.71592963],\n",
       "       [-57.04943162, -55.31730791, -53.41538831, ...,   7.63232142,\n",
       "          0.17062221,  -8.31863568],\n",
       "       [-53.39220572, -51.79042304, -50.05551126, ...,   1.37057563,\n",
       "         -7.27389954, -16.39497486]])"
      ]
     },
     "execution_count": 251,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_X_loaded[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 309,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(48,)"
      ]
     },
     "execution_count": 309,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_Y_loaded[test_Y_loaded==2145].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "ename": "OSError",
     "evalue": "/Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all/testY.csv not found.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mOSError\u001b[0m                                   Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-3e8494ba9dc3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtestY\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloadtxt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput_path\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m'/testY.csv'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdelimiter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m','\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py\u001b[0m in \u001b[0;36mloadtxt\u001b[0;34m(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)\u001b[0m\n\u001b[1;32m    979\u001b[0m             \u001b[0mfname\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mos_fspath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    980\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0m_is_string_like\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 981\u001b[0;31m             \u001b[0mfh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_datasource\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'rt'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mencoding\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mencoding\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    982\u001b[0m             \u001b[0mfencoding\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfh\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'encoding'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'latin1'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    983\u001b[0m             \u001b[0mfh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfh\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(path, mode, destpath, encoding, newline)\u001b[0m\n\u001b[1;32m    267\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    268\u001b[0m     \u001b[0mds\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mDataSource\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdestpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 269\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0mds\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mencoding\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mencoding\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnewline\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnewline\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    270\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    271\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/anaconda3/lib/python3.7/site-packages/numpy/lib/_datasource.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self, path, mode, encoding, newline)\u001b[0m\n\u001b[1;32m    621\u001b[0m                                       encoding=encoding, newline=newline)\n\u001b[1;32m    622\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 623\u001b[0;31m             \u001b[0;32mraise\u001b[0m \u001b[0mIOError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"%s not found.\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    624\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    625\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mOSError\u001b[0m: /Users/aring/Desktop/ECG-identification/Arnold-data/nn-input-all/testY.csv not found."
     ]
    }
   ],
   "source": [
    "testY = np.loadtxt(output_path+'/testY.csv', delimiter=',')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(45308, 7)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "RepDiagnosisDF = pd.read_excel(RepDiagnosisFileName)\n",
    "\n",
    "FullDiagnosisDF = pd.read_excel(FullDiagnosisFileName)\n",
    "print(FullDiagnosisDF.shape)\n",
    "\n",
    "\n",
    "NonRepDiagnosisDF = FullDiagnosisDF.loc[~FullDiagnosisDF['FileName'].isin(RepDiagnosisDF['FileName'])]\n",
    "NonRepDiagnosisDF = NonRepDiagnosisDF.reset_index(drop=True)\n",
    "NonRepDiagnosisDF['PatientID'] = NonRepDiagnosisDF['FileName']\n",
    "\n",
    "AllDiagnosisDF = pd.concat([RepDiagnosisDF, NonRepDiagnosisDF])\n",
    "AllDiagnosisDF = AllDiagnosisDF.reset_index(drop=True)\n",
    "le = preprocessing.LabelEncoder()\n",
    "AllDiagnosisDF['PatientID'] = AllDiagnosisDF['PatientID'].astype('str')\n",
    "AllDiagnosisDF['PatientID_new'] = le.fit_transform(AllDiagnosisDF['PatientID'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FileName</th>\n",
       "      <th>PatientID</th>\n",
       "      <th>DOB</th>\n",
       "      <th>Age</th>\n",
       "      <th>Gen</th>\n",
       "      <th>TimeAcquisition</th>\n",
       "      <th>Translation</th>\n",
       "      <th>PatientID_new</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MUSE_20180113_180130_23000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>85</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/12/2016 10:52:16</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MUSE_20180113_180131_30000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>29/05/2017 10:10:54</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MUSE_20180113_180139_35000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>03/06/2017 07:34:27</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MUSE_20180113_180143_59000</td>\n",
       "      <td>219</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Male</td>\n",
       "      <td>04/11/2017 11:46:50</td>\n",
       "      <td>['Sinus_Tachycardia']</td>\n",
       "      <td>1673</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MUSE_20180113_131105_22000</td>\n",
       "      <td>542</td>\n",
       "      <td>1011931.0</td>\n",
       "      <td>86</td>\n",
       "      <td>Female</td>\n",
       "      <td>26/01/2017 12:50:33</td>\n",
       "      <td>[ 'Ventricular_Escape_Beat']</td>\n",
       "      <td>2269</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     FileName PatientID        DOB Age     Gen  \\\n",
       "0  MUSE_20180113_180130_23000       219  1011931.0  85    Male   \n",
       "1  MUSE_20180113_180131_30000       219  1011931.0  86    Male   \n",
       "2  MUSE_20180113_180139_35000       219  1011931.0  86    Male   \n",
       "3  MUSE_20180113_180143_59000       219  1011931.0  86    Male   \n",
       "4  MUSE_20180113_131105_22000       542  1011931.0  86  Female   \n",
       "\n",
       "       TimeAcquisition                   Translation  PatientID_new  \n",
       "0  29/12/2016 10:52:16         ['Sinus_Tachycardia']           1673  \n",
       "1  29/05/2017 10:10:54         ['Sinus_Tachycardia']           1673  \n",
       "2  03/06/2017 07:34:27         ['Sinus_Tachycardia']           1673  \n",
       "3  04/11/2017 11:46:50         ['Sinus_Tachycardia']           1673  \n",
       "4  26/01/2017 12:50:33  [ 'Ventricular_Escape_Beat']           2269  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AllDiagnosisDF.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "AllDiagnosisDF[['PatientID']].to_csv('/Users/aring/Desktop/ECG-identification/patient-ids.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "AllDiagnosisDF[['PatientID','PatientID_new']].to_csv('/Users/aring/Desktop/ECG-identification/patient-ids-old-and-new.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
